Maven Pom Update - maven

I am using Spring Tool Suite (STS) for my Spring boot application development.
I am using the Spring Started Project option to select the component required for my applications. For example: if I want to develop web application, I will select the "web" check box and spring io initailzier will download all the required jars in the classpath with help of maven.
Suppose, after the project creation for WEB, If I want to add some other components in my existing web project like using Eureka, Hystrix, the required jars are not automatically setup in the classpath and couldn't use the annotation like #EnableEurekaClient as it throws error as jar is missing.
I have manually updated the pom.xml to include the Eureka starter/client/server dependency and trying to update the project (Project >> Maven >> Update Project), so that required jars will be in classpath. But it is not happening.
Any advise on it..thanks.

Related

Converting existing project to Spring boot project in InelliJ

I have an existing project. I need to make it a Spring boot based project and I am using IntelliJ CE.
What would be correct procedure for doing it?
Edit:
Project has no initial structure. It is a totally empty project. So no existing modules etc.
Spring Boot is an Ultimate feature, so first you would need to try/buy the IntelliJ IDEA Ultimate.
From there, you can add Spring support to existing project modules or use the Spring Initializr wizard to select the necessary configuration when creating a new project or module.
In your maven pom.xml or build.gradle file, I would add the spring boot starter dependency:
spring-boot-starter (the group id is org.springframework.boot)
If the application is a web application, I would also add the web starter spring-boot-starter-web also with the same group id (org.springframework.boot)
For convenient features, applying the spring boot plugin would help in creating a runnable jar with all required dependencies bundled called a fat jar.
A great tool I use is the spring boot project generator. It allows you to configure the modules you want and create a project template.
Spring Boot requires IntelliJ IDEA Ultimate. If you want to use IntelliJ CE, please create a project using Spring Initilizer then import the same to your IntelliJ CE (File -> Open -> Choose the project root folder). After you import the project, wait for some time so that IntelliJ can download the dependency and build your project. You can check from (Build -> Build your project). Then find the main class of spring boot and run it using the green play button

When spring applications with gradle multi-module run on intellij's dashboard, it can't load property sources

I setup spring boot applications project with gradle multi module project. Each module is just spring boot application. To run all applications, i have to refresh all module using refresh gradle project on root project. On the other hand, If i refresh a specific gradle module, other applications which also are submodule cannot load property source.
For a detailed explanation, i want to present sample application:
https://github.com/samplesrepo/sample-demonstrating-boot-cannot-load-propertysource-in-multi-module
And i uploaded a video demonstrating this problem in youtube:
(https://www.youtube.com/watch?v=5kGu6MhHfmY)

Spring Boot web app without maven

Friends,
I am trying to build a Spring boot project. but the challenge is maven isn't working in office environment(basically proxy isn't allowing).
Is there any way to create a spring boot project without maven?
if I can get any boiler code link would be very helpful.
Yes, it is possible. Just add all the necessary jar in project class path manually. Example Spring boot project jar added by gradle.
Part1
Part2

Spring Boot multi module WAR Generation

I have made a maven Spring boot (REST) Project that has 3 (maven) sub modules (i. api ii. implementation and iii. service modules).
The main method (#SpringBootApplication) is in the root of the project. The REST web service works fine from IDE but maven does not allow me to package this project as war and deploy to external tomcat.
To solve this I added a new module and added dependencies of other modules within this and packaged this as war (by adding maven-war-plugin). But when deployed on server; the webservice does not get hit.
Structure-
Service Project
main()(This is within root project)
api module
service module
implementation module
Newly added module (that has above 3 modules injected as dependency and the plugin that let me package this as a war)
Expecting a war that has all these submodules that can be deployed on external Tomcat 9 server.
How to achieve this?
Please Note - I have added spring-boot-maven-plugin
to repackage in the root project, but it is not working.
Adding parent to this newly added module fixed the issue and I was able to make a working jar!

Spring Boot Gradle - avoid lib-provided folder in war file

I have a Spring Boot based application and I'm trying to switch over from Maven to Gradle. The application is supposed to build a war file, which is deployed to a web server (WildFly in our case).
Now, I have some libraries provided by the web server and thus using a "providedCompile" scope (For hibernate search and infinispan). Now, when used with Spring Boot plugin, the plugin is creating the war file with all the "providedCompile" libraries moved to a folder named "lib-provided".
How do I avoid this? On the same context, it is also adding the Spring Boot loader classes on to the war file. If possible, I need to avoid this too.
Please help! Thanks!
If you're only ever going to deploy your application as a WAR file to an app server, then you don't need it to be turned into an executable archive. You can disable this repackaging in your build.gradle file:
bootRepackage {
enabled = false
}

Resources