JAXB2导入:无法处理模式文件(在udemy中为28分钟)

时间:2019-04-18 18:48:35

标签: java maven eclipse-plugin pom.xml jaxb2-maven-plugin

当我尝试添加JAXB2插件时,在<exception>行上收到“无法处理架构文件”错误。

pom.xml

    <plugins>
        <!-- JAXB2 Maven Plugin -->
        <!-- XSD Source Folder -->
        <!-- Java Class Source Folder -->
        <!-- clear folder -> false -->
    <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <id>xjc</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
                <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                <clearOutputDir>false</clearOutputDir>
            </configuration>
        </plugin>
    </plugins>

错误截图:

enter image description here

1 个答案:

答案 0 :(得分:0)

我遇到类似的问题,只是要确保xsd文件具有

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</xsd:schema>

不是

<schema xmlns="http://www.w3.org/2001/XMLSchema">
</schema>`