我无法构建Maven项目

时间:2014-11-18 10:12:11

标签: maven-3 java-ee-7 wildfly-8

请问我是maven项目和wildfly(JBoss)服务器的新手。我有一个Java EE 7项目,我使用NetBeans为Apache Tomcat 8开发。出于某种原因,我想迁移到WildFly 8.

我已经在JBoss Studio 7.1上重新创建了具有所有Maven依赖项的项目。首次尝试运行该项目将返回“禁止”。

我试图通过运行

来确保项目得到遵守和部署
mvn clean package
Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ProjectName 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ProjectName ---
[INFO] Deleting /path/to/the/ProjectName/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ProjectName ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ProjectName ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 74 source files to /path/to/the/ProjectName/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.062 s
[INFO] Finished at: 2014-11-18T10:58:47+01:00
[INFO] Final Memory: 8M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ProjectName: Compilation failure -> [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

我用-e

重新运行命令
------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project nants: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project nants: Compilation failure
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    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:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    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)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:862)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
[ERROR] 

这些提示包含我的环境

Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T21:58:10+01:00)
Maven home: /path/to/maven
Java version: 1.8.0_20, vendor: Oracle Corporation
Java home: /usr/lib/jvm/oracle_jdk_8/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-24-generic", arch: "amd64", family: "unix"

我阅读了建议的wiki,但仍无法解决问题。也许是因为我还是新人。请感谢你帮我解决这个错误。

2 个答案:

答案 0 :(得分:1)

您正在使用Java 8,请尝试使用Java 7,因为某些组件可能不支持Java 8。 此处描述了类似的问题:maven-compilation-fails-without-explaining-why

答案 1 :(得分:1)

我终于找到了编译失败的问题,我已经通过纠正我的POM.xml修复了我的JAVA_HOME设置错误。虽然我仍然从网址获得“禁止”,如果我无法解决它,将需要一个不同的问题线程。

<maven.compiler.executable>/absolute/path/to/bin/javac</maven.compiler.executable>

TO:

<maven.compiler.executable>${JAVA_HOME}/bin/javac</maven.compiler.executable>