Dependency Scope for Lombok

Lombok is a popular Java library that simplifies development by automating boilerplate code generation.

Lombok is only required during compile time, not runtime. If you don’t specify the correct scope, Lombok might be included in your runtime environment.

To avoid that, we use the “provided” scope when including Lombok in your pom.xml file. This scope indicates that the dependency is required for compilation but not for runtime. By specifying “provided”, you ensure that Lombok is only used during compilation and not packaged in your final artifact.

<dependencies>
	<dependency>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
		<version>1.18.32</version>
		<scope>provided</scope>
	</dependency>
</dependencies>

Reference:

For more information on setting up Lombok with Maven, refer to the official Lombok documentation: https://projectlombok.org/setup/maven

Leave a comment