如何在intellij中调试springboot maven应用程序

时间:2017-11-29 13:00:20

标签: java maven debugging spring-boot intellij-idea

我想在intellij Idea中以调试模式启动spring-boot maven应用程序,但是当我创建断点时,应用程序不会挂起并继续前进。我已经阅读了很多主题,但我仍然不明白该怎么做。你能帮我决定最好的行动方案。

编辑:我使用spring-boot-maven-plugin和Maven Run / Debug配置与spring-boot:在命令行中运行。

编辑:所以当我将Jvm Arguments添加到pom.xml时,我收到了这样的日志:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
              <configuration>
                <jvmArguments>
                    -Xdebug - Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 
                </jvmArguments>
            </configuration>
        </plugin>
    </plugins>
</build>

但是当请求localhost:5005 / myPage时,我收到错误101(net :: ERR_CONNECTION_RESET)。似乎有些maven参数没有指定。

这是我在pom.xml中的maven plagin:

{{1}}

2 个答案:

答案 0 :(得分:0)

在“运行/调试配置”中,在命令行中输入以下内容:

spring-boot:run -Dspring.profiles.active=local,vl -Dfork=false -f pom.xml

添加了-D fork=false后,我的Maven spring-boot:run配置调试就很好了。

答案 1 :(得分:0)

您可以在CLI中使用以下命令:

export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n

以下是我的项目设置:

enter image description here