maven-3 - 通过maven编译时出现SAXParseException

标签 maven-3 jaxb2 saxparseexception

大家好,我知道以前可能有人问过这个问题,所以提前抱歉(没有足够的代表对其他线程发表评论)

当我通过 mvn 编译我的项目时,我得到一些 SAXParse 异常,即使我可以毫无问题地构建和运行我的项目。我只是清理一些构建警告,想知道为什么会发生这种情况...任何帮助都非常感谢

日志......

[INFO] --- jaxb2-maven-plugin:1.6:xjc (Shop) @ the-project ---
[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:140)
at com.sun.tools.xjc.Driver.run(Driver.java:361)
at org.codehaus.mojo.jaxb2.AbstractXjcMojo.execute(AbstractXjcMojo.java:316)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

POM...

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
    <execution>
        <id>The</id>
        <goals>
            <goal>xjc</goal>
        </goals>
        <configuration>
            <schemaIncludes>
                <include>The.xsd</include>                              
            </schemaIncludes>
            <schemaDirectory>${schema.directory.The}</schemaDirectory>
            <packageName>${generated.source.The}</packageName>
            <verbose>true</verbose>
            <clearOutputDir>false</clearOutputDir>
        </configuration>
    </execution>
</executions>

最佳答案

我遇到了同样的问题,问题是详细标志已打开,并且详细日志记录只是为了记录而创建错误。

XJC 代码中基本上存在一个“bug”,他们调用的地方

//生成实际代码 receive.debug("生成代码");

并编写调试语句

public final void debug( String msg ) {
    info( new SAXParseException(msg,null) );
}

然后调用

public void info(SAXParseException exception) {
    if(opt.verbose)
       super.info(exception);
 }

因此,由于记录器的实现方式,它会记录完整的堆栈跟踪。这更有趣,因为 SAXParseException 只是为了创建日志语句而创建的,并且永远不会抛出。

关于maven-3 - 通过maven编译时出现SAXParseException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28903669/

相关文章:

eclipse "Creation of Element Failed"

java - cvc-复杂类型.3.2.2 : Attribute xsi:schemaLocation is not allowed to appear in <people> in Java DOM

java - JAXB 2.0 - 如何编码(marshal)静态内部类

java - jaxb,子元素的单独命名空间

spring - java.lang.NoClassDefFoundError : org/apache/tiles/TilesApplicationContext

java - 来自类加载器层次结构的警告 : Failed to scan <>. jar。 FileNotFoundException异常

java - maven-eclipse-插件 : how to force to use a jar dependency rather than project dependency

java - 使用 Reflections google library 的单元测试仅在由 Maven 执行时失败

Java:从 .xml 文件填充 .xsd 生成的类