Debugging not working for Spring Boot 2.2 and IntelliJ Idea - spring-boot

By running the app in debugging mode (spring-boot:run) with IntelliJ Idea CE, no breakpoints work at all when using Spring Boot 2.2. Instead, when rolling back to Spring Boot 2.1.1, everything works fine. What am I doing wrong? Is there an option/flag to add for 2.2 to make the debugger work?

I would recommend running the app directly from the IDE rather than using mvn spring-boot:run. Doing so will give you the best experience in the IDE.
The release notes indicate that the Spring Boot Maven Plugin now forks the process by default which is the reason why you can't debug the application as you used to with 2.1. If you really have to run the app using the maven plugin, you can disable forking the process (e.g. using -Dspring-boot.run.fork=false)

Edit Configuration -> Application -> in Main Class: select your Main class (the one that contain your main method(public static void main) ) and run

Related

Debug Spring Boot 3 in IntelliJ Community

Since the migration to Spring Boot 3 my application doesn't hold at breakpoints any more, when I run the Maven Spring Boot goal mvn spring-boot:run.
This is because Spring forks the thread or the process and the debugger is not attached to this.
In former Spring-Boot versions you could disable forking by passing -Dspring-boot.run.fork=false (see How to debug spring-boot application with IntelliJ IDEA community Edition?).
Unfortunatly this option was removed as you can read in the Spring Boot 3.0 Migration Guide:
The fork attribute of spring-boot:run and spring-boot:start that was deprecated in Spring Boot 2.7 has been removed.
Is there any possibility to make breakpoints work again?
Ideas so far
Of course IntelliJ Ultimate has better Spring Boot integration. I'm trying to make it work with the Community Edition.
I also tried not to run the Maven goal but to make an Application run configuration. This failed so far, because of java.lang.ClassNotFoundException, it doesn't find the Main class. Not sure if I should investigate that option further.
Last idea was to start the Maven goal with debug options such that an external debugger can attach. That didn't work either and even if it would, I could only attach the debuger after startup with would make debugging the creation of spring context impossible.

can you help me fix my STS? as it is not working

I am new to STS and trying to run my first project in it. But it is not showing me run on server option. I have tried "clean install" but still, it is not working. When I checked targeted runtimes it is not showing any server in it. Kindly help me to resolve this issue.
My recommendations for getting started with the Spring Tools 4 for Eclipse are:
start the IDE with an empty workspace
create a new Spring Boot project using the wizard "Import Spring Getting Started Content" to import some getting started guides, for example the Rest Service example
if you decide to create an empty new Spring project, use the wizard "Spring Starter Project" - it is the direct integration for https://start.spring.io - and go from there
All those options get you started with a Spring Boot project which doesn't need a separate server to run on. Spring Boot comes with am embedded server component, so you can just start the Spring Boot application as a regular Java app. No need to install a local server or use the "Run on Server" option in the IDE.

Adding a gatling test to a Spring Boot gradle project on IntelliJ

I have a Spring Boot 2 application written in Kotlin (could be Java). The project uses gradle (not maven). The application exposes HTTP endpoints that I want to load test using gatling.
I created a MySimulation.scala file under src/test/gatling. IntelliJ suggested and I accepted the intallation of the Scala IntelliJ plugin. So, I got syntax highliting on the scala editor. :^)
I'd like to have code assist (drill down, code completion) for the scala gatling tests.
What other tools/plugins/configuration do I need to add?
(I have the gatling bundle already installed on my computer. IntelliJ version is 2018.2.4.)

Spring loaded 1.2.5 + Spring Boot 1.3.2. can't seem to get it to work

I came across a video on youtube ( https://www.youtube.com/watch?v=GTrNkhVnJBU ) where it demos Spring Loaded.
I'm trying to duplicate the same behavior but am still unsuccessful so far.
What I'm using:
Spring Tool Suite 3.7.2
Spring Boot 1.3.2-RELEASE
Spring loaded 1.2.5-RELEASE
Maven version 3.1.0
JDK 1.8.0_71
I tried the same thing as the guy does in the video (except for the versions being more up to date of course) but it doesn't work.
I also tried the "maven plugin" way as described in the spring docs here -> https://docs.spring.io/spring-boot/docs/current/reference/html/howto-hotswapping.html#howto-reload-springloaded-maven
But that also did not work.
I tried changing the versions of spring loaded to 1.2.0 (docs use that version) but that didn't do anything either.
I ran the app in STS itself, and also tried mvn spring-boot:run from command line, but both simply don't get the desired result.
When using mvn spring-boot:run I see that it is attaching the agent:
[INFO] Attaching agents: [C:\Users\ron.m2\repository\org\springframework\springloaded\1.2.5.RELEASE\springloaded-1.2.5.RELEASE.jar]
But changing RequestMappings or method signatures do not get picked up by spring loaded and thus the change is not reflected.
I'm a little out of ideas why I can't get this to work and any help would be greatly appreciated.
Spring loaded does not yet support spring 4.2. See https://github.com/spring-projects/spring-loaded/issues/139
So you either stick with DevTools which definitely speeds up the development process (although not as fast as spring-loaded), use JRebel (which supports the latest spring version) or downgrade to spring 4.1.
As an alternative you could also try the automatic restart feature of Spring Boot Devtools: https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3. It restarts just the app and it is much quicker than restarting the whole JVM. You are loosing application state though, but it might be an alternative.

Running a Spring MVC program in Intellij

I am a past Eclipse user and been using Intellij for 2 months on. However I am only been using it for Spring-Boot apps. I decided to make a fun Spring MVC app and I cannot figure out how to get it to deploy and run on my tomcat server. For spring boot it is pretty simple.
I was hoping someone could help me out with this.
The above picture show my options. I am using Intellij 14 full version if that matters.
Hope to hear from someone soon.
We can use Tomcat7 Plugin for running our App on IntelliJ
Follow this steps :
Click on Add Configuration
Click on +
You need to create a configuration for your Tomcat Server first.
If you don't see TomcatServer option when you try to create a configuration, you might need to enable Tomcat and TomEE Integration Plugin first by going to File -> Settings -> Plugins.
After you create a configuration for your server, you should be able to see options to run your spring application in the server.
You may also modify/configure how to run your app in the Deployment tab in your Tomcat configuration.
You need to package it using some tool or IDE.
And then to deploy
result package to your tomcat server with Idea plugin or any deploy
tool you like.
Also you can configure maven to do both targets easily.
Update: you can choose your Tomcat/TomcatEE goal in menu like at your screenshot and provide required server info here like host, port, etc.. And on the deployments page add your application artifact. And then save this build profile and use it with run>>run in main menu of IDE
No need to install tomcat server locally. You can use Tomcat7 Plugin in your pom and run it without any other configuration.

Resources