我在将项目迁移到Java 9.
更新 Java 9 后,我尝试运行项目,但遇到编译器错误:-
Error:(6, 1) java: package javax.annotation is not visible
(package javax.annotation is declared in module java.xml.ws.annotation, which is not in the module graph)
但我找到了如何解决它的解决方案。I added lombok.config
file.
然后添加后module-info.java
文件到项目编译器再次显示错误
Error:(10, 26) java: variable title not initialized in the default constructor
项目示例:
我们有实体Store
:
@AllArgsConstructor
@Getter
public class Story {
private final String title;
}
在 root 的包中我有module-info.java
内容:
module javanine {
requires lombok;
}
在 root 的项目中我有龙目岛配置文件:
lombok.addJavaxGeneratedAnnotation = false
lombok.anyConstructor.suppressConstructorProperties = true
config.stopBubbling = true
在代码中的某个地方我称之为:
public static void main(String[] args) {
Story story = new Story("how as");
System.out.println(story.getTitle());
}