This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Lombok not working with STS

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am following this book on Spring.

I stumbled on a small problem. Namely, on Chapter 2, we are supposed to create a domain class called Ingredient (for ordering tacos..). The author explained reasons why we should use lombok for this class. I followed author's instructions on how to install lombok, but STS is still reporting errors. I went on lombok's web site to follow up how to install .jar for STS and I tried MANY tips from SO, but nothing worked. Bellow are my steps (and current setup on my comp)  I used for trying to set up lombok.

1. Folder where STS is installed


2. pom.xml


3. spring starters


4. Ingredient

Hope someone can explain to me how to fix this, so I can continue with learning Spring/Spring Boot.
 
Bartender
Posts: 2483
108
Google Web Toolkit Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think sts has to be configured to use Lombok. The eclipse.ini or sts.ini should contain:

-javaagent:somepath/lombok.jar

You should be able to go to your machine's .m2 folder and run.
java -jar lombok.jar


Having said that .. I'm not particularly fond of this api.
 
Mike Gosling
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you salvin francis for replying.

salvin francis wrote: The eclipse.ini or sts.ini should contain:

-javaagent:somepath/lombok.jar



This is the content of my SpringToolsSuite4.ini (i thnik that is sts.ini) file.

When I go to look for lombok.jar in m2 folder. This is how I do:



and this is the content of the destination folder.

Once I type this command in cmd (after positioning in the location above):



I get Installation wizard, like this.

Assuming I need to specify location for SpringToolSuite4, I do so by selecting installation folder where STS is located. This is how it looks like. This is final look on wizard before hitting Install/Update button.

If I go back again to folder where STS is installed (unzipped), this is how it looks like. Jar lombok is present. New content of .ini file, now, I have that line you mentioned in your post. I am not sure if that is correct.

Once start STS again, it complains that it doesn't see lombok.

WHERE I'M I WRONG?
 
salvin francis
Bartender
Posts: 2483
108
Google Web Toolkit Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please PostTextNotScreenshots <-- It's a link.

From what I understand in your screenshots, Eclipse/STS is setup properly. But, your specific project does not contain the jar yet. I think your pom.xml is not valid. The dependency does not look right to me.

If you're using lombok 1.18.10, your pom.xml should look like this:


 
Mike Gosling
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Damn, it is working now! Thank you Salivn Francis. One small thing, STS is saying that <version> is not required in pom.xml.

I'll make sure to follow the forum rule you pointed out.

Thank you one more time.

P.S. If anyone in future stumbles on similar problem and is reading this, and links here are broken, fell free to PM me and if I know, I'll help.
 
salvin francis
Bartender
Posts: 2483
108
Google Web Toolkit Eclipse IDE Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just if you're interested, we've had a conversation about this library in this thread
 
Sheriff
Posts: 7423
505
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike Gosling wrote:The author explained reasons why we should use lombok for this class


Would you mind to share with us what reasons were mentioned?
 
Mike Gosling
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll just give you big quote from the book:



As you can see, this is a run-of-the-mill Java domain class, defining the three properties needed to describe an ingredient. Perhaps the most unusual thing about the Ingredient class as defined above is that it seems to be missing the usual set of getter and setter methods, not to mention useful methods like equals(), hashCode(), toString(), and others. You don’t see them in the listing partly to save space, but also because you’re using an amazing library called Lombok to automatically generate those methods at runtime. In fact, the @Data annotation at the class level is provided by Lombok and tells Lombok to generate all of those missing methods as well as a constructor that accepts all final properties as arguments. By using Lombok, you can keep the code for Ingredient slim and trim.

Lombok isn’t a Spring library, but it’s so incredibly useful that I find it hard to develop without it. And it’s a lifesaver when I need to keep code examples in a book short and sweet.
 
Liutauras Vilda
Sheriff
Posts: 7423
505
Mac OS X VI Editor BSD Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

Seem to be very weak arguments to use it. Hard to notice any actually. By the way, Lombok generates code at compile time, not runtime as the book suggests. I would recommend to forget this library in Java ecosystem and avoid using it.
 
Mike Gosling
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:Seem to be very weak arguments to use it. Hard to notice any actually. By the way, Lombok generates code at compile time, not runtime as the book suggests. I would recommend to forget this library in Java ecosystem and avoid using it.



Thank you for giving better clarification. Tho, I'm not using Lombok for the sake of Lombok, rather to follow up the author. It seems that he uses Lombok throughout the book.
 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!