mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
需要在idea 中edit configuration->+ -> remote->debug
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的比较多。
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/")
}
}
采用gradle自带属性debug模式.结果好像不能用啊。直接看方法3吧。
在project根目录下创建gradle.properties.
添加:
org.gradle.debug=true
然后命令行:
gradlew bootRun --debug
看到显示:
接着在idea中 edit configuration->+ -> remote->debug
在build.gradle中添加:
bootRun {
jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
}
然后:
gradlew bootRun --debug
直接:
gradle bootRun --debug-jvm