Maven编译失败 [英] maven compilation failure

查看:87
本文介绍了Maven编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题-在Maven构建期间无法读取某些类文件.

I have a weird problem - Some class file couldn't be read during maven build.

  1. 我有一个项目A和项目B.
  2. 项目B取决于项目A目标JAR文件.
  1. I have a project A and project B.
  2. Project B depends on the project A target JAR file.

在项目B编译期间,尽管指向它的部分是完美的,但无法读取项目A JAR文件中的lib.

During the project B compilation it is not able to read lib in the project A JAR file - though the part directed to it is perfect.

我还检查并验证了Maven脚本,它是完美的.

I have also checked and verified the maven script and it is perfect.

错误:

[INFO] Compiling 137 source files to V:\dhs_tss_build_view\dhs_tssproject\tss\tsscommon-server\target\classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

V:/dhs_tss_build_view/dhs_tssproject/tss/tsscommon-server/src/main/java/us/mn/state/dhs/tss/common/oblix/da/wsdl/OblixLoginAc
cess.java:[51,60] cannot find symbol
symbol  : class BusinessException
location: class us.mn.state.dhs.tss.common.oblix.da.wsdl.OblixLoginAccess

V:/dhs_tss_build_view/dhs_tssproject/tss/tsscommon-server/src/main/java/us/mn/state/dhs/tss/common/app/da/ldap/BaseLdapImpl.j
ava:[187,14] cannot find symbol
symbol  : class Phone
location: class us.mn.state.dhs.tss.common.app.da.ldap.BaseLdapImpl

V:/dhs_tss_build_view/dhs_tssproject/tss/tsscommon-server/src/main/java/us/mn/state/dhs/tss/common/app/da/ldap/BaseLdapImpl.j
ava:[204,14] cannot find symbol
symbol  : class Phone
location: class us.mn.state.dhs.tss.common.app.da.ldap.BaseLdapImpl


[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.BuildFailureException: Compilation failure
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:579)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330
)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
        at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
        at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
        ... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 56 seconds
[INFO] Finished at: Mon Oct 19 09:46:53 CDT 2009
[INFO] Final Memory: 11M/20M
[INFO] ------------------------------------------------------------------------

推荐答案

我遇到了同样的问题,这就是我建议您解决的方法:

I had the same problem and this is how I suggest you fix it:

运行:

mvn dependency:list

并仔细阅读是否有警告消息表明某些依赖项将没有可用的传递性依赖项.

and read carefully if there are any warning messages indicating that for some dependencies there will be no transitive dependencies available.

如果是,请使用-X标志重新运行它:

If yes, re-run it with -X flag:

mvn dependency:list -X

查看详细信息,Maven抱怨什么(-X标志可能会有很多输出)

to see detailed info what is maven complaining about (there might be a lot of output for -X flag)

在我的情况下,依赖的maven模块pom.xml中存在一个问题-具有托管依赖项.尽管在父pom中定义了托管依赖项的版本,但是Maven无法解决它,并且抱怨依赖项pom.xml中缺少版本.

In my case there was a problem in dependent maven module pom.xml - with managed dependency. Although there was a version for the managed dependency defined in parent pom, Maven was unable to resolve it and was complaining about missing version in the dependent pom.xml

所以我只配置了缺少的版本,问题就消失了.

So I just configured the missing version and the problem disappeared.

这篇关于Maven编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆