java – Maven编译器插件错误:无法访问枚举(错误签名,坏类)
我正在使用maven-compiler-plugin:2.3.2并且每当我在导入中具有枚举(ContentType)的类中进行更改时,我需要清理,否则它会给我:
ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project wp2: Compilation failure [ERROR] /home/semyon/development/.../ContentManager.java:[15,46] error: cannot access ContentType [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project wp2: Compilation failure /home/semyon/development/.../ContentManager.java:[15,46] error: cannot access ContentType 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.MojoExecutor.executeForkedExecutions(MojoExecutor.java:364) ... ContentType是枚举,如下所示: import org.jetbrains.annotations.NotNull; public enum ContentType { ...; private final String title; private final boolean hasJad; private final CoreType coreType; private final String[] searchKeywords; ContentType(@NotNull String title,CoreType coreType,boolean hasJad,String[] searchKeywords) { this.title = title; this.coreType = coreType; this.hasJad = hasJad; this.searchKeywords = searchKeywords; } @NotNull public String getTitle() { return title; } @NotNull public String getName() { return name(); } @NotNull public CoreType getCoreType() { return coreType; } public enum CoreType { ...; private String title; CoreType(String title) { this.title = title; } public String getTitle() { return title; } } } UPD1,项目结构: /wp2 /core /cpe /widget /ContentManager.java /cdr /entities /ContentType.java UPD 2: ContentManager.java:[15,46]是导入wp2.core.cdr.entities.ContentType; UPD 3: 解决方法
我终于找到了答案
错误发生在costructor中: ContentType(@NotNull字符串标题… 枚举中的构造函数不能包含注释,因为javac会被窃听. tl; dr从构造函数中删除注释,javac是错误的 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |