- 本文作者:@Ryan Miao
- 本文链接:www.cnblogs.com/woshimrf/p/…
- 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!
目录
命令行方式:
热部署:
debug启动:
方法1:
方法2:
方法3:
-
maven
- gradle
Maven:
命令行方式:
mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
需要在idea 中edit configuration->+ -> remote->debug
rum main方法:
debug run
热部署
在pom里添加:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
<dependencies>
<!-- spring热部署-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
然后修改类后,在idea中重新编译该类:build->recompile XXXX
或者使用快捷键ctrl+shif+F9
Gradle:
近来发现使用gradle的比较多。
热部署:
buildscript {
repositories { jcenter() }
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.1.BUILD-SNAPSHOT"
classpath 'org.springframework:springloaded:1.2.0.RELEASE'
}
}
apply plugin: 'idea'
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/main/")
}
}
debug启动:
方法1:
采用gradle自带属性debug模式.结果好像不能用啊。直接看方法3吧。
在project根目录下创建gradle.properties.
添加:
org.gradle.debug=true
然后命令行:
gradlew bootRun --debug
看到显示:

接着在idea中 edit configuration->+ -> remote->debug
方法2:
在build.gradle中添加:
bootRun {
jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
}
然后:
gradlew bootRun --debug
方法3:
直接:
gradle bootRun --debug-jvm
So do it,and change it,no regret!