zoukankan      html  css  js  c++  java
  • spring boot 调试

    • 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

     from

    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

    参考:http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-remote-debug-gradle-run

  • 相关阅读:
    MVC之路由规则 (自定义,约束,debug)
    MCV之行为
    mvc之页面强类型
    Jquery异步上传图片
    三层VS控制器
    Oracle 表分区
    C#编写的通过汉字得到拼音和五笔码
    MYSQL存储过程学习
    Sina App Engine(SAE)入门教程(9)- SaeMail(邮件)使用
    状态CSS
  • 原文地址:https://www.cnblogs.com/woshimrf/p/springboot-hotload-debug.html
Copyright © 2011-2022 走看看