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

lex*_*ope 7 java jaxb schemagen java-7

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

<groupId>com.sun.tools.jxc.maven2</groupId>
<artifactId>maven-jaxb-schemagen-plugin</artifactId>
<version>1.2</version>
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

[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
Run Code Online (Sandbox Code Playgroud)

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

Don*_*ows 9

你尝试过使用它org.codehaus.mojo:jaxb2-maven-plugin吗?

  • 所以这个插件似乎有效.一个缺点是,似乎不可能使用此插件命名输出模式文件,因此我不得不求助于使用maven-antrun-plugin重命名模式文件.此外,我收到警告"警告:计划在下一个主要的JDK版本中删除apt工具及其关联的API." - 希望这个混乱将在java 8之前解决 (2认同)

yeg*_*256 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>
Run Code Online (Sandbox Code Playgroud)