从 XSD 生成 Bean 时,jaxb2-maven-plugin 始终打印警告

发布于 2024-09-13 23:19:49 字数 1760 浏览 3 评论 0原文

我正在尝试使用 jaxb2-maven-plugin maven 插件从 xsd 生成 bean,但是每次生成 bean 时我都会收到以下警告。请注意,结果 bean 可以工作。 有人知道为什么会发生这种情况吗?

--snip--
[INFO]    task-segment: [deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [jaxb2:xjc {execution: default}]
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] compiling a schema...
[WARNING] null[-1,-1]
org.xml.sax.SAXParseException: generating code
        at com.sun.tools.xjc.ErrorReceiver.debug(ErrorReceiver.java:113)
        at com.sun.tools.xjc.Driver.run(Driver.java:315)
        at org.codehaus.mojo.jaxb2.XjcMojo.execute(XjcMojo.java:301)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
--snip--

这是 pom.xml 中的配置

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <packageName>com.some.package.jaxb</packageName>
                <verbose>true</verbose>
            </configuration>
        </plugin>

虽然我认为我在技术上使用 2.0.3 (而不是 2.0),但以下是引发此问题的代码行:

**如果我在 pom 中将 verbose 设置为 false,我不会收到警告。这只是一个草率的日志机制吗? **

谢谢

--马蒂亚斯

I'm trying to generate beans from an xsd by using the jaxb2-maven-plugin maven plugin, however each time the beans are generated i get the following warning. Note that the result beans work. Does anyone know why this happens?

--snip--
[INFO]    task-segment: [deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [jaxb2:xjc {execution: default}]
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] compiling a schema...
[WARNING] null[-1,-1]
org.xml.sax.SAXParseException: generating code
        at com.sun.tools.xjc.ErrorReceiver.debug(ErrorReceiver.java:113)
        at com.sun.tools.xjc.Driver.run(Driver.java:315)
        at org.codehaus.mojo.jaxb2.XjcMojo.execute(XjcMojo.java:301)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
--snip--

This is the config in the pom.xml

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <packageName>com.some.package.jaxb</packageName>
                <verbose>true</verbose>
            </configuration>
        </plugin>

While i think i'm technically using 2.0.3 (not 2.0), here is the line of code that starts this issue:
http://grepcode.com/file/repo1.maven.org/maven2/com.sun.xml.bind/jaxb-xjc/2.0/com/sun/tools/xjc/Driver.java#315

**If i set verbose to false in the pom i don't get the warning. Is this just a sloppy logging mechanism? **

Thanks

--Matthias

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

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

发布评论

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

评论(2

半衾梦 2024-09-20 23:19:49

“问题”在于详细选项设置为 true - 如果您将其删除,警告就会消失。

The "problem" lies in verbose option set to true - it you'll take it out, the warning disappears.

揽月 2024-09-20 23:19:49

@lexcore,你是对的。看来您的“事实上的”标准实际上是一个更好的选择,并且效果同样好。根据记录,这是一篇关于差异的好文章。

这是我使用的配置。我很难追踪到它所在的仓库。希望这对某人有帮助:

        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.7.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <verbose>true</verbose>
                <schemaDirectory>src/main/xsd</schemaDirectory>
                <generatePackage>com.ninja.jaxb</generatePackage>
            </configuration>
        </plugin>
 ...
<repositories>
    <repository>
        <id>maven-repo2</id>
        <name>Maven Repository</name>
        <url>http://repo2.maven.org/maven2</url>
    </repository>
</repositories>

@lexicore, you are right. It seems like your "de-facto" standard is actually a better choice, and works just as good. For the record this is a good read about the differences.

This is the config i used. I had trouble tracking down what repo it was on. Hopefully this helps someone:

        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.7.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <verbose>true</verbose>
                <schemaDirectory>src/main/xsd</schemaDirectory>
                <generatePackage>com.ninja.jaxb</generatePackage>
            </configuration>
        </plugin>
 ...
<repositories>
    <repository>
        <id>maven-repo2</id>
        <name>Maven Repository</name>
        <url>http://repo2.maven.org/maven2</url>
    </repository>
</repositories>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文