您的当前位置:首页正文

为 springboot 添加 debug功能

来源:九壹网

两种运行方式

springboot 的项目(组建)有两种方式。

其中第1个能很方便地debug
但是, 跟spring 的插件thymeleaf (代替mvc)冲突.

第一种方式运行时, 会找不到项目的网页资源文件。

第二钟方法能避免呢个问题, 但系default没有提供调试功能。

解决方法

1. 在pom.xml 添加remote debug的属性

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

2.在Idea(现在流行这个, 应该讲大部分网上视频用呢个ide)run - Edit configuration 的截面, 添加1个remote的item

什么也不用改,按默认就得

3. 其实配置完成, 用mvn: springboot:run 运行项目

4.在debug工具栏, 选择刚刚新建的远程debug 项目, 然后按debug按钮

小结

吴复杂, 就系要同时启动两个项目, 1个本项目, 1个远程调试…

因篇幅问题不能全部显示,请点此查看更多更全内容

Top