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

发布于 2024-12-20 22:36:39 字数 823 浏览 1 评论 0原文

当我尝试将 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

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

When I try to use maven-jaxb-schemagen-plugin with java 7

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

I get an error:

[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

It seems like the AnnotationProcessorFactory is being removed/deprecated in Java 7? Is it possible to get jaxb schemagen to work using this plugin? Is there an alternative approach to get schema generation from the JAXB source code when using JDK 7?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

贱人配狗天长地久 2024-12-27 22:36:39

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

Have you tried using the org.codehaus.mojo:jaxb2-maven-plugin instead?

心清如水 2024-12-27 22:36:39

它的工作原理如下(将此配置文件添加到您的 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>

This is how it works (add this profile to your 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>
长途伴 2024-12-27 22:36:39

不确定是否有人再听这个线程,但是,嘿……

我使用了 transformSchemas 选项,例如

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

Cheers

-m。

Not sure anyone is listening to this thread anymore but, what the hey...

I used the transformSchemas option e.g.

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

cheers

-m.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文