./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
Use lombok annotations for my custom POJOs setter/getter and builder.
Maven build failed.
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
{
"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"
}
}
JHipster doesn't offically support Lombok. Please use stackoverflow to ask for help.
See #3895 and other Lombok issues.
Yes and I'll need to update my list of days lost because of Lombok... Why the hell do people use it?
possibly Lombok is an example for anti-patterns, looks like a good idea, while it's actually not 馃槃
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 ?
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...
Ok I see, I'm one of this "lazy" guys :)
Beyond Jpa - Hibernate , do you plan to support mybatis? I use to use it and Spring Boot too.
"smart", I said "smart" :-)
I explain that, as Julien did this so many times. We have some policies. In general, they are talking about providing a minimum of fancy stuff, and try to be maximal conform with default configuration. Sure, there are tons of different solutions in every single stack JHipster provides, as Lombok for POJOs, Mybatis as Hibernate replacement, minimum 1337 different (distributed) caching solutions, angular plugins etc...
As soon as we decide to support one more of those options, we are responsible for offering a working solution across all future releases. The more new stuff we support, the longer it takes to create the next really stable release. The benefit for the majority of our users is small, while the waiting time for useful stuff gets long.
That's why we focus on the necessary features, which helps a lot of people.
Especially that I don't get why people do hype Lombok so hard. The most of them are using IntelliJ or Eclipse, where you just do a fast combo and get your getter/setters
Ok I get it. I have to stick to JHipster policies because it's a great generator which do cool things. Thanks guys.
@freemanpolys
I have no problem using lombok in JHipster projects. Are you sure you configured everything correctly?
I don't make any configuration usually with my Spring Boot project. I just add the dependency and use Lombok @Data , @Builder annotations. As JHipster does much more than Spring Initializer, I was supposing that it will behave and do at least things that Spring Boot project use to do :(
Anyway @andidev, which configs do you do ?
Not sure, but we added the Afterburner module for Jackson recently : that's the kind of thing that won't work well with Lombok
Ok @jdubois. @andidev, we have to definitely stick to JHipster policies :-)
I think this is a lombok issue, try downgrading lombok.
see
https://github.com/rzwitserloot/lombok/issues/979
and
https://stackoverflow.com/questions/34358689/maven-build-cannot-find-symbol-when-accessing-project-lombok-annotated-methods
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.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<!-- For JPA static metamodel generation -->
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<version>${maven-compiler-plugin.version}</version> ... <version>${hibernate.version}</version>
version numbers?
Please don't comment on an old issue.
If you think this issue still applies, please create a new ticket with proper details.
If you have a question please use Stack Overflow, and tag the question with jhipster. This helps the project to keep the issue tracker clean. Also, Stack Overflow will give your question a larger audience:
Most helpful comment
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.