首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jaxb2-maven-plugin Error java11 schema_reference

Jaxb2-maven-plugin Error java11 schema_reference
EN

Stack Overflow用户
提问于 2019-11-05 17:16:09
回答 1查看 560关注 0票数 1

使用JDK11运行jaxb2-maven-plugin (2.5.0)时出现错误。

pom.xml:

代码语言:javascript
复制
<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>xjc_test</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>../a/b/c/myschema.xsd</source>
                        </sources>
                        <clearOutputDir>false</clearOutputDir>
                        <outputDirectory />
                    </configuration>
                </execution>
            </executions>
</plugin>

错误:

代码语言:javascript
复制
 [ERROR] null [-1,-1] 
org.xml.sax.SAXParseException; schema_reference.4: Failed to read schema document 'file:/home/userE/eclipse-workspace-201809/parent/testjaxb/home/userE/eclipse-workspace-201809/parent/a/b/c/myschema.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.5.0:xjc (xjc_test) on project xxx:

[ERROR] +=================== [XJC Error]
[ERROR] |
[ERROR] | 0: file:/home/userE/eclipse-workspace-201809/parent/a/b/c/myschema.xsd
[ERROR] |
[ERROR] +=================== [End XJC Error]

如果我在pom.xml中放置了错误的源路径,它将失败,因此我可以假定它找到了正确的.xsd文件。我不理解schema_reference,它是从哪里来的。

对于信息,我的.xsd看起来是这样的:(他在另一个项目中)

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    ...
</xs:schema>
EN

回答 1

Stack Overflow用户

发布于 2021-04-23 18:01:27

尝试像这样引用basedir:

代码语言:javascript
复制
..    
<sources>                                
   <source>${project.basedir}/src/main/resources/your_folder/your_xsd.xsd</source>
</sources>
..
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58708002

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档