是否有可能让maven-jaxb-schemagen-plugin与Java 7一起使用?

时间:2011-12-13 17:11:06

标签: java jaxb java-7 schemagen

当我尝试将maven-jaxb-schemagen-plugin与java 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

似乎在Java 7中删除/弃用了AnnotationProcessorFactory?有可能让jaxb schemagen使用这个插件工作吗?在使用JDK 7时,是否有其他方法可以从JAXB源代码生成模式?

3 个答案:

答案 0 :(得分:9)

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

答案 1 :(得分: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>

答案 2 :(得分:0)

不确定是否有人正在听这个帖子,但嘿嘿......

我使用了transformSchemas选项,例如

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

欢呼声

-m