8

当我尝试使用maven-jaxb-schemagen-pluginjava 7

<groupId>com.sun.tools.jxc.maven2</groupId>
<artifactId>maven-jaxb-schemagen-plugin</artifactId>
<version>1.2</version>

我收到一个错误:

[ERROR] Failed to execute goal com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate (default) on project TopologyProvisionerDom: Execution default of goal com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate failed: A required class was missing while executing com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate: com/sun/mirror/apt/AnnotationProcessorFactory

似乎AnnotationProcessorFactory在 Java 7 中被删除/弃用了?是否可以使用此插件使 jaxb schemagen 工作?使用 JDK 7 时,是否有另一种方法可以从 JAXB 源代码生成模式?

4

3 回答 3

9

您是否尝试过org.codehaus.mojo:jaxb2-maven-plugin使用

于 2011-12-13T17:38:06.083 回答
7

这就是它的工作原理(将此配置文件添加到您的pom.xml):

<profile>
    <id>jdk7-fix</id>
    <activation>
        <file><exists>${java.home}/../lib/tools.jar</exists></file>
    </activation>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.sun.tools.jxc.maven2</groupId>
                    <artifactId>maven-jaxb-schemagen-plugin</artifactId>
                    <dependencies>
                        <dependency>
                            <groupId>com.sun</groupId>
                            <artifactId>tools</artifactId>
                            <version>1.7</version>
                            <scope>system</scope>
                            <systemPath>${java.home}/../lib/tools.jar</systemPath>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</profile>
于 2012-08-02T15:22:07.930 回答
0

不知道有没有人在听这个话题了,但是,嘿……

我使用了这个transformSchemas选项,例如

<transformSchemas>
    <transformSchema>
        <uri>YOUR NS IN YOUR GENERATED SCHEMA FILE</uri>
        <toFile>DESIRED NAME OF YOUR XSD FILE</toFile>
    </transformSchema>
</transformSchemas>

干杯

-米。

于 2015-09-24T05:58:06.733 回答