我在Maven中有一个编译错误但在
Eclipse中一切顺利.
有什么我做错了或是Maven bug吗?
我创建了一个代码片段,因此您可以尝试重现它.
以下是Java源文件和pom.xml.
package p1;
import p1.A.D.C;
import p1.p2.E;
public class A {
interface B {
T methodB();
}
class D implements B {
C c = new C();
public C getC() {
return c;
}
class C {
public void methodC() {
System.out.println(this);
}
}
@Override
public E methodB() {
return new E();
}
}
public void methodA() {
D d = new D();
d.methodB();
C c = d.getC();
c.methodC();
}
public static void main(String[] args) {
A a = new A();
a.methodA();
}
}
package p1.p2;
public class E {
}
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
mvntst
test
0
jar
mvntst
当我运行mvn clean compile时,我得到了这个输出:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test: Compilation failure
[ERROR] /C:/dev/test/CompilerTest/MavenTest/src/main/java/p1/A.java:[6,30] cannot find symbol
[ERROR] symbol: class E
[ERROR] location: class p1.A
[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
这是mvn –version的结果:
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T23:10:27+03:00)
Maven home: C:\dev\apache-maven-3.3.1\bin\..
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_40\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"