简体   繁体   English

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

[英]How to debug springboot maven application in intellij

I want to start spring-boot maven application in debug mode in intellij Idea, but when I make breakpoints the application doesn't suspend and goes further.我想在 intellij Idea 中以调试模式启动 spring-boot maven 应用程序,但是当我设置断点时,应用程序不会暂停并继续运行。 I've read a lot of topics but I still don't understand how to do it.我已经阅读了很多主题,但我仍然不明白如何去做。 Could you help me decide the best course of action.你能帮我决定最好的行动方案吗?

Edit: I use spring-boot-maven-plugin and Maven Run/Debug configuration with spring-boot:run in command line.编辑:我在命令行中使用 spring-boot-maven-plugin 和 Maven Run/Debug 配置和 spring-boot:run 。

Edit: So when I added Jvm Arguments to pom.xml I recieved such log:编辑:所以当我将 Jvm Arguments 添加到 pom.xml 时,我收到了这样的日志:

[INFO] Scanning for projects...
[INFO]                                                                         

[INFO] ------------------------------------------------------------------------
[INFO] Building shop 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> spring-boot-maven-plugin:1.5.8.RELEASE:run (default-cli) > test-compile @ shop >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ shop ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ shop ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ shop ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Валера\IdeaProjects\shop\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ shop ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< spring-boot-maven-plugin:1.5.8.RELEASE:run (default-cli) < test-compile @ shop <<<
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.5.8.RELEASE:run (default-cli) @ shop ---
[INFO] Attaching agents: []
Listening for transport dt_socket at address: 5005

But when requesting localhost:5005/myPage I recieve Error 101 (net: : ERR_CONNECTION_RESET).但是当请求 localhost:5005/myPage 时,我收到错误 101(网络::ERR_CONNECTION_RESET)。 Seems like some maven arguments did not specify.似乎一些 Maven 参数没有指定。

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

<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>

In your Run/Debug Configurations enter the following into your command line:在您的运行/调试配置中,在命令行中输入以下内容:

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

My Maven spring-boot:run configuration debugs just fine with the -D fork=false added.我的 Maven spring-boot:run 配置调试很好,添加了-D fork=false

You may use below command in the CLI:您可以在 CLI 中使用以下命令:

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

Below is my project settings:以下是我的项目设置:

enter image description here在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM