我的主类引用了一个Settings.java
类,并且在不引用新属性的情况下运行 maven,当我这样做时它可以正常工作:
mvn assembly:assembly
如果我引用一个新属性,我会收到此错误:
[ERROR] /Users/.../service.java:[41,58] cannot find symbol
[ERROR] symbol : method getDefaultScore()
这是一个多 Maven 项目。该依赖项是一个本地依赖项,它只是另一个 maven 模块,所以不确定它为什么不选择这个新属性。
我确实mvn clean
在根目录下运行,以防缓存的东西。
注意:当我通过 IntelliJ 构建和运行此应用程序时,它运行良好,但使用 maven 它似乎不喜欢这个新属性(它不仅仅是一个返回我分配的值的字符串属性,它不是t 从属性文件或任何东西中读取)。
使用调试运行时:
mvn assembly:assembly -X
我得到相同的“找不到符号”,位置是我的另一个 Maven 模块的类,然后我得到:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myapp-jobs: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
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.MojoExecutor.executeForkedExecutions(MojoExecutor.java:365)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
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:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
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:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 23 more
只是为了确保,我用旧的属性替换了新属性的引用,并且 mvn 命令运行良好,所以它是 def。新属性有问题,很简单:
public class Settings {
..
..
private String defaultScore = "100";
public String getDefaultScore() {
return defaultScore;
}
}
我的电脑/Maven 版本等:
- 阿帕奇 Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
- Maven 主页:/Users/../java/apache-maven-3.0.3
- Java 版本:1.6.0_31,供应商:Apple Inc.
- Java 主页:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
- 默认语言环境:en_US,平台编码:MacRoman
- 操作系统名称:“mac os x”,版本:“10.7.4”,arch:“x86_64”,系列:“mac”