[증상]

IDE (vscode, sts, eclipse)가 아닌 cli에서 maven compile시 annotationProcessor가 적용되지 않아 compile error가 발생하는 경우

$ mvn clean compile

 

공식홈페이지에는 아래와 같이 설정하면 된다고 나와 있는데, 해당 방식으로 동작하지 않음

Adding lombok to your pom file

To include lombok as a 'provided' dependency, add it to your <dependencies> block like so:

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

JDK9+ with module-info.java

The configuration of the compiler plug-in should contain the following:

<annotationProcessorPaths>
	<path>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
		<version>1.18.36</version>
	</path>
</annotationProcessorPaths>

 

공식사이트: https://projectlombok.org/setup/maven

 

[해결방안]

pom.xml의 maven-compiler-plugin에 명시적으로 annotationProcessorPaths를 적용

<project>
  <build>
    <plugins>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
          <annotationProcessorPaths>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>${lombok.version}</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>
      
    <plugins>      
  <build>
<project>

+ Recent posts