2

I am trying to debug the REST API I have built using maven, however, whenever I stop the debugger, it shows a message:

Disconnected from the target VM, address: '127.0.0.1:50047', transport: 'socket'

And the remote process still seems to be running:

enter image description here

Is there a way to fix it so that when I stop the debugger, the process also stops running?

here is my POM.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>jetbrains</groupId>
    <artifactId>ProductProject</artifactId>
    <version>1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
    </parent>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>2.3.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
            <version>2.3.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.12</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.2.8.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

</project>

run configuration has spring-boot:run in the command line field and working directory is my project folder

Kris
  • 562
  • 5
  • 17
  • Can you verify by trying to access the given IP+Port? I'm not sure if this is expected behavior based on your maven script. – dbl Sep 02 '20 at 10:17
  • Most probably the `red skull` icon should terminate the instance. – dbl Sep 02 '20 at 10:19
  • I can still send a GET request to the port through postman and receive a response. Also if I try to rerun it, it says that the Port 8080 is already in use. – Kris Sep 02 '20 at 10:21
  • red skull icon doesn't seem to do anything when clicked – Kris Sep 02 '20 at 10:24
  • Can you provide your `pom.xml` and `run configuration`. – dbl Sep 02 '20 at 10:36
  • added my pom.xml and run configuration to the post – Kris Sep 02 '20 at 10:41
  • Is this a behavior that is present only for debugging? I haven't touched spring apps for more than a year, but I had no such issues back then...Stopping the debugger was killing the background process as well. It looks like a IntelliJ misconfiguration but have no clue how to fix it at that point. – dbl Sep 02 '20 at 10:53
  • yeah, this only happens when I am debugging, running and stopping it works as normal and the process gets killed. – Kris Sep 02 '20 at 10:55
  • [This one](https://stackoverflow.com/questions/36745457/why-does-intellij-idea-not-kill-the-debug-process-immediately#:~:text=Start%20a%20debugging%20session%2C%20wait,button%20(CTRL%2DF2).) seems to be related. – dbl Sep 02 '20 at 10:56

2 Answers2

2

Enable "Kill the debug process immediately" option in "Settings (Preferences)| Build, Execution, Deployment | Debugger"

enter image description here

Nemanja
  • 3,295
  • 11
  • 15
2

SOLVED: Adding <version> 1.2.7.RELEASE </version> to the spring-boot-maven-plugin in the POM.xml seems to have fixed the issue. Read that it was something to do with forking.

Kris
  • 562
  • 5
  • 17