I faced problem during migration our project to Java 9.
After I've updated Java 9, I attempt to run project, I faced with compiler errors :-
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)
but I found the solution how to resolve it. I added lombok.config
file.
Then after adding module-info.java
file to project compiler is displayed errors again
Error:(10, 26) java: variable title not initialized in the default constructor
Project example:
We have entity Store
:
@AllArgsConstructor
@Getter
public class Story {
private final String title;
}
in root's package I have module-info.java
with content:
module javanine {
requires lombok;
}
and in root's project I have lombok.config file with:
lombok.addJavaxGeneratedAnnotation = false
lombok.anyConstructor.suppressConstructorProperties = true
config.stopBubbling = true
and somewhere in the code I call it :
public static void main(String[] args) {
Story story = new Story("how as");
System.out.println(story.getTitle());
}
Latest version of Lombok and/or IntelliJ plugin perfectly supports Java 11.
Pretty sure Lombok supports JDK 6+, so there is no reason for you to change version.
The downside is it clutters your source with boilerplate code that take the focus off the important stuff. After 5 months, we're still using Lombok, but I have some other annoyances. The lack of a declared getter & setter can get annoying at times when you are trying to familiarize yourself with new code.
The project Lombok is a popular and widely used Java library that is used to minimize or remove the boilerplate code. It saves time and effort. Just by using the annotations, we can save space and readability of the source code. It is automatically plugging into IDEs and build tools to spice up our Java application.
It is also known as Project Jigsaw. In this Java 9 modules example, we will learn about modules (in general) and how your programming style will change in the future when you start writing modular code. 1. What is a Module?
A module is typically just a jar file that has a module-info.class file at the root. To use a module, include the jar file into modulepath instead of the classpath. A modular jar file added to classpath is normal jar file and module-info.class file will be ignored.
It’s an Independent module and does NOT dependent on any other modules. By default, all other modules are dependent on “ java.base “. In Java 9, modules help us in encapsulating packages and managing dependencies.
By default, all other modules dependent on “ java.base ”. In java 9, modules helps you in encapsulating packages and manage dependencies. So typically, a class is a container of fields and methods. a package is a container of classes and interfaces. a module is a container of packages.
Just configure your module as following:
module moduleName {
requires static lombok;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With