代码之家  ›  专栏  ›  技术社区  ›  mlathe

jaxb2maven插件在从XSD生成bean时总是输出警告

  •  7
  • mlathe  · 技术社区  · 14 年前

    我试图使用jaxb2 maven plugin maven plugin从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--
    

            <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>
    

    http://grepcode.com/file/repo1.maven.org/maven2/com.sun.xml.bind/jaxb-xjc/2.0/com/sun/tools/xjc/Driver.java#315

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

    谢谢

    --马蒂亚斯

    2 回复  |  直到 14 年前
        1
  •  9
  •   Dmitry    14 年前

        2
  •  5
  •   Community CDub    7 年前

    @利克索,你说得对。看起来你的“事实上的”标准实际上是一个更好的选择,而且效果一样好。为了记录在案,这是一本关于 differences

            <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>