Home > Enterprise >  Understanding STS: Spring boot application works fine from STS but when gradle is used to build jar,
Understanding STS: Spring boot application works fine from STS but when gradle is used to build jar,

Time:10-29

My spring boot application works fine when run from Spring Tool Suite. However at the time of project deployment when I use Gradle command to build jar file, I get compile error - with error message saying a specific package is missing. The root cause was that I had missed to add a specific dependency to build.gradle. After adding the missing dependency the build was successful.

Can someone explain how STS was able to refer to the "missing" dependency and able to run the application successfully in development environment? Is it that STS and Gradle has two different locations where dependencies are stored?

CodePudding user response:

When using STS (or any other IDE for that matter) and you are manually (or through a wizard) adding jars to the classpath entries those will only be available in your IDE.

What you should be doing is adding additional dependencies to your pom.xml or build.gradle (depending on your tooling), which then in turn should be picked up by your IDE again.

NOTE: Some IDEs will automatically detect additions to the classpath and add them to your build files as well. Not sure if STS (and thus Eclipse) does this.

  • Related