Maven 命令打包是老是编译异常?

在CMD命令行里,我用mvn clean package打包,总是编译异常。我在Eclipse跑命令可以通过编译!


D:\Workspaces\eclipse\payment-settlement>mvn clean package -D maven.test.skip=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building payment-settlement Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ payment-settlement ---
[INFO] Deleting D:\Workspaces\eclipse\payment-settlement\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ payment-settlement ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ payment-settlement ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to D:\Workspaces\eclipse\payment-settlement\target\classes
编译器 (1.7.0_25) 中出现异常错误。。 如果在 Bug Parade 中没有找到该错误, 请在 Java Developer Connection (http://java.
sun.com/webapps/bugreport) 中建立 Bug。。请在报告中附上您的的程序和以下诊断信息。。谢谢谢谢。。
java.lang.ArrayIndexOutOfBoundsException: 98565
        at com.sun.tools.javac.file.ZipFileIndex.get4ByteLittleEndian(ZipFileIndex.java:476)
        at com.sun.tools.javac.file.ZipFileIndex.access$500(ZipFileIndex.java:80)
        at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.readEntry(ZipFileIndex.java:602)
        at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.buildIndex(ZipFileIndex.java:580)
        at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.access$000(ZipFileIndex.java:484)
        at com.sun.tools.javac.file.ZipFileIndex.checkIndex(ZipFileIndex.java:192)
        at com.sun.tools.javac.file.ZipFileIndex.<init>(ZipFileIndex.java:137)
        at com.sun.tools.javac.file.ZipFileIndexCache.getZipFileIndex(ZipFileIndexCache.java:100)
        at com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:548)
        at com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:482)
        at com.sun.tools.javac.file.JavacFileManager.listContainer(JavacFileManager.java:368)
        at com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:644)
        at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2499)
        at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2143)
        at com.sun.tools.javac.code.Symbol.complete(Symbol.java:421)
        at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:298)
        at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:459)
        at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
        at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
        at com.sun.tools.javac.comp.Enter.complete(Enter.java:484)
        at com.sun.tools.javac.comp.Enter.main(Enter.java:469)
        at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:929)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
        at com.sun.tools.javac.main.Main.compile(Main.java:439)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
        at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
        at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
        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:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        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)
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] An unknown compilation problem occurred
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.013s
[INFO] Finished at: Tue Jan 17 13:57:40 CST 2017
[INFO] Final Memory: 13M/244M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project payment-settlement: Compilation failure
[ERROR] An unknown compilation problem occurred
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

POM.xml配置

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId></artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name></name>
    <url>http://maven.apache.org</url>

    <properties>
        <spring.version>4.0.5.RELEASE</spring.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>

        <filters>
            
        </filters>

        <resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                    <exclude>generatorConfig.xml</exclude>
                </excludes>
            </resource>
        </resources>
    </build>
</project>

求解?

阅读 10.7k
2 个回答

换一个JDK试试?比如1.8版本的。

可能是版本的兼容问题

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题