I'm setting my first steps into a SpringBoot maven application. It has a root pom file, a module with a pom file and a Java class.
This is the root pom.xml file of my project.
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp</groupId>
<artifactId>dummy</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<properties>
<!-- Project revision -->
<revision>local-SNAPSHOT</revision>
<!-- Dependency versions -->
<lombok-version>1.18.38</lombok-version>
<springboot-version>3.3.10</springboot-version>
<springjdbc-version>6.2.9</springjdbc-version>
</properties>
<modules>
<module>dummy-service</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>21</source>
<target>21</target>
<proc>none</proc>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>1.14</version>
<configuration>
<includedScopes>compile</includedScopes>
<excludedGroups>com.myapp.*</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>21</source>
<target>21</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok-version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
This root pom has 1 module, the dummy-service. This is the pom file of my dummy-service module.
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.trax</groupId>
<artifactId>scheduler</artifactId>
<version>${revision}</version>
</parent>
<groupId>com.trax.scheduler</groupId>
<artifactId>scheduler-service</artifactId>
<name>scheduler-service</name>
<dependencies>
<!-- SpringBoot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${springboot-version}</version>
</dependency>
<!-- spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${springjdbc-version}</version>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
Inside this dummy-service module I have a class DataLoaderConfig
package com.myapp.dummy.service;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class DataLoaderConfig {
public void execute() {
log.info("Executing...");
}
}
However this runs successfully in IntelliJ, I have an issue during maven compilation:
cannot find symbol [ERROR] symbol: variable log
I verified that the Maven pom has the lombok dependency, also that during build the annotation processor is executed, but still the issue occurs. I guess I'm doing something wrong, but the question is what exactly went wrong?
Looks like <proc>none</proc> within maven-compiler-plugin's configuration prevents annotation processing. I was able to compile your project successfully after removing it.
From maven-compiler-plugin documentation:
<proc> Sets whether annotation processing is performed or not. Only applies to JDK 1.6+ If not set, both compilation and annotation processing are performed at the same time.
Allowed values are:
none
- no annotation processing is performed.
only
- only annotation processing is done, no compilation.
full
- annotation processing and compilation.full is the default. Starting with JDK 21, this option must be set explicitly. [...]