generator-jhipster: Can't compile with lombok
Overview of the issue
./mvnw and mvn clean install fail when adding lombok dependency but run successfully when launched from Intellij IDE Find the error below :
INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] src/main/java/web/rest/core/service/impl/ProductServiceImpl.java:[18,29] cannot find symbol
symbol: method builder()
location: class com.test.one.web.rest.core.model.Product
Motivation for or Use Case
Use lombok annotations for my custom POJOs setter/getter and builder.
Maven build failed.
Reproduce the error
add lombok dependency in the pom.xml
<!-- jhipster-needle-maven-add-dependency -->
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
<scope>provided</scope>
</dependency>
create new java class as below
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class Product {
private String name;
}
Run ./mvnw or maven clean install
JHipster Version(s)
generator-jhipster@4.4.1
JHipster configuration
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.test.one",
"nativeLanguage": "fr"
},
"jhipsterVersion": "4.4.1",
"baseName": "airpayapi",
"packageName": "com.test.one",
"packageFolder": "com/test/one",
"serverPort": "8081",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "maven",
"enableSocialSignIn": false,
"enableTranslation": true,
"applicationType": "microservice",
"testFrameworks": [
"gatling"
],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"nativeLanguage": "fr",
"languages": [
"fr",
"en"
],
"clientPackageManager": "yarn"
}
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (10 by maintainers)
The maven project Jhipster generated uses a annotationProcessorPaths in the maven compile plugin, that’s why it cannot look up the latest lombok unless we specify lombok as one of the annotation processor.
Working code is as followed.
Because we do so much more than Spring Initializer… I’ve spent so many days on projects failing because of Lombok, I have no idea why people want to use this. There’s one “smart” guy who gains a few minutes for not generating his getter/setter, and then you have whole teams stuck, production system failing, and consultants billed to solve the issue. That thing is costing so many $$$. Note that I shouldn’t complain too much, I’m one the guys who are paid to solve those issues… Already happened on 4 different projects, and counting…
Yes and I’ll need to update my list of days lost because of Lombok… Why the hell do people use it?
We use Lombok to avoid writing annoying setter/getter and it inject builder pattern too 😃 @PierreBesson I don’t understand, JHispter is just a Spring Boot + Angular project generator right ? Why is Lombok working in a Spring Initializr project and not in in a JHipster one ?
“smart”, I said “smart” 😃