Reputation: 3015
I have following maven structure:
parent-module
|-model-module
|-model-contributor-module
In model-module
I have entities that annotated with @lombok.Data
. When I make mvn clean install
on model-module
everything is ok. Second inner module model-contributor-module
contains model-module
in dependencies. When I try to do the same build on model-contributor-module
, I receive an error cannot find symbol
.
pom.xml
for model-module
:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
And pom.xml
for model-contributor-module
:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
.....
<pluginManagement>
<plugins>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.8.0</version>
</plugin>
</plugins>
</pluginManagement>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.8.0</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>testDelombok</goal>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
How to fix these compilation errors?
[ERROR] /Users/superuser/Documents/workspace/project/test/src/main/java/com/company/services/impl/MyServiceImpl.java:[291,65] cannot find symbol
[ERROR] symbol: method getUserId()
Upvotes: 0
Views: 3412
Reputation: 2104
Move that lombok dependency into the parent pom's dependencyManagement element so it can be inherited by the child modules. You have the plugin available in all modules, but it looks like the lombok dependency is only available in model-module.
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
Upvotes: 6