运行一个SpringBoot多模块应用

使用SpringBoot配置启动:

Use classpath of module选中要运行的模块

VM options:内部配置参数

-Dserver.port= -Dspring.profiles.active=test -Ddebug

server.port可以设置端口号,spring.profiles.active=test可以设置运行环境

-Ddebug 开启debug模式

这种方式的好处就是不用对代码进行任何变动,比较方便。

使用maven启动:

不同版本的spring-boot-maven-plugin的jvm参数配置有所不同,同时与通过main方法启动springboot程序传递参数也有所不同。

在运行main方法时,可以通过java -jar 后面通过添加-D的参数即可传递,比如:

java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 huishi-api-implementation.jar

参考:

java -Djsse.enableSNIExtension=false -Xmx1200m -XX:MaxPermSize=256M  -agentlib:jdwp=transport=dt_socket,server=y,address=,suspend=n -jar mac-quickstart-2.0.jar -gui

pom.xml文件配置:

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>

此时运行spring-boot:run,是可以正常传递参数。但此时通过mvn spring-boot:run命令来传递参数,参数值将会无效。

同样,即使项目中pom文件配置了上面的plugin,直接通过main方法启动,此参数也是不会生效的。打包部署时依旧需要在执行命令中添加参数项。

这种方式要改动文件,对于提交比较麻烦,不太喜欢。

idea中对springboot进行热部署

1.SpringLoaded

使用pom.xml修改

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2..RELEASE</version>
</dependency>
</dependencies>
</plugin>

或者添加vm参数:

-javaagent:D:\maven\repository\org\springframework\springloaded\1.2..RELEASE\springloaded-1.2..RELEASE.jar -noverify

我比较喜欢添加vm参数的方式

这种方式系统会监视classes文件,当有classes文件被改动时,系统会重新加载类文件,不用重启启动服务。

2.使用spring-boot-devtools

pom.xml中添加

<!-- ideal修改文件自动重启工具 ,eclipse不需要 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>

将依赖关系标记为可选<optional>true</optional>是一种最佳做法,可以防止使用项目将devtools传递性地应用于其他模块。

这种方式是使用自动重启

自动重启的原理在于spring boot使用两个classloader:不改变的类(如第三方jar)由base类加载器加载,正在开发的类由restart类加载器加载。应用重启时,restart类加载器被扔掉重建,而base类加载器不变,这种方法意味着应用程序重新启动通常比“冷启动”快得多,因为base类加载器已经可用并已填充。

所以,当我们开启devtools后,classpath中的文件变化会导致应用自动重启。

总之上面这两种方式都是在改动class文件的时候才会进行热部署,所以要手动进行编译或者开始idea的自动编译。

3.jrebel插件,以前还好破解,现在越来越难破解,没钱,pass.

比较好的文章:

http://tengj.top/2017/06/01/springboot10/

参考:

http://blog.hanqunfeng.com/2016/12/09/spring-boot-study/

https://blog.csdn.net/wo541075754/article/details/75017014

https://stackoverflow.com/questions/42618277/how-to-set-a-run-debug-configuration-in-intellij-idea-using-a-jar-file

https://blog.kazaff.me/2014/07/28/java%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%BF%90%E8%A1%8C%E5%8F%82%E6%95%B0/

http://xinklabi.iteye.com/blog/837435

http://jadyer.cn/2016/07/29/idea-springboot-jsp/

http://www.tianshouzhi.com/api/tutorials/jvm/99

IntelliJ IDEA 中SpringBoot对Run/Debug Configurations配置 SpringBoot热部署的更多相关文章

  1. IntelliJ IDEA中Spring Boot项目使用spring-boot-devtools无法实现热部署/热更新的问题解决

    这个设置真的和Eclipse有很大区别,Eclipse中只要运行之后就可实现修改文件自动重启.但IDEA不太一样,需要做如下配置: 前提: 1.添加spring-boot-devtools到POM. ...

  2. IDEA Run/Debug Configurations 中点击“+”号没有tomcat server选项

    环境: 版本:IntelliJ IDEA 2016.3.2系统:windows7 32位 / ubuntu上通用 2.问题: 在IDEA中,对每一个web项目都要配置tomcat服务器,如果你是第一次 ...

  3. 安卓 运行、调试 配置 android Run/debug configurations

    android  运行.调试 配置 android  Run/debug configurations 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:313134555@qq. ...

  4. android run/debug configurations时报错Cannot reload AVD list:

    问题:配置Android的run/debug configurations时报错Cannot reload AVD list: cvc-enumeration-valid: Value '280dpi ...

  5. Intellij IDEA 配置jrebel热部署

    Jrebel 先介绍一下jrebel,jrebel是可以热部署项目的一个工具,更改代码自动部署并不需要重启项目(在spring中的controller中,增加.修改方法都是可以进行热部署而不需要重启的 ...

  6. springboot配置idea 热部署

    背景: 在开发中,当我们修改代码之后,每次都要重新启动,很是浪费时间,在springboot中就有一种热部署方式,可以实现想要修改不需要每次都重新启动,保存即可生效 用法: 一.maven 添加   ...

  7. idea开发时springboot项目时的自动编译和热部署

    前提:最好将idea的启动器设置一下 操作:1.file > Build,Execution,Deployment > Compiler 勾选 Build project automati ...

  8. IDEA run/debug configurations中没有配置tomcat选项

    原文链接:https://blog.csdn.net/qq_41016818/article/details/80871738 原因分析 没有配置tomcat插件 解决方法如下: file->s ...

  9. 找回IntelliJ IDEA中 丢失的Run Dashboard 视图

    一般有时候创建springboot项目的时候右下角可以提示你打开Run Dashboard,但是如果不提醒就需要自己配置了. 找到项目中.idea文件下的workspace.xml开打 接下来找到 & ...

随机推荐

  1. HashMap(JDK1.8)

      四个构造函数: 构造方法只是赋值属性初始值但是不会真正初始化数组表空间,在第一次添加元素时形成数组表空间.这个和以往的jDK1.7之前的不同,1.7之前的都是在构造里初始化了table数组空间. ...

  2. linux系统状态检测命令

    1.ifconfig命令 ifconfig命令用于获取网卡配置与网络状态等信息,格式为“ifconfig [网络设备] [参数]”. 使用ifconfig命令来查看本机当前的网卡配置与网络状态等信息时 ...

  3. <7>Lua类的表的实例创建

    根据上一节知识所述Lua中没有像C.C++.JAVA中的类概念,面向对象等 ,但我们可以模拟出来 如下 代码如下: --创建类的表 local Person = {} function Person: ...

  4. ModuleNotFoundError: No module named '_pydevd_bundle.pydevd_cython' error on debug

    现象:pycharm调试代码出现错误:ModuleNotFoundError: No module named '_pydevd_bundle.pydevd_cython' error on debu ...

  5. MQTT 发布者订阅者

    添加依赖: <dependency> <groupId>org.eclipse.paho</groupId> <artifactId>org.eclip ...

  6. 反射(I)

    反射获取属性和属性值 let item = DoctorGroup() guard let dic = InterfaceTests.obtainValues(subObject: item) els ...

  7. rabbitMq 教程

    https://github.com/401Studio/WeekLearn/issues/2 目录 RabbitMQ 概念 exchange交换机机制 什么是交换机 binding? Direct ...

  8. 1分钟完美安装最新CentOS+Nginx+PHP-FPM+MySQL

    PHP 5.3.1 MySQL 5.0.89 Nginx 0.8.33 或 0.7.65 (可选) 现在,我们可以快速全自动搞定 CentOS + Nginx + PHP-FPM + MySQL 的安 ...

  9. zabbix 监控项(key)

    Key 描述 返回值 参数 详细说明 agent.hostname 返回被监控端名称 字符串 - 返回配置文件中配置的被监控端的名称 agent.ping 检测被监控端是否存活 1 - 运行中 其他 ...

  10. html5的理解

    1.良好的移动性,以移动设备为主 2.响应式设计,以适应自动变化的屏幕尺寸 3.支持离线缓存技术,webStorage本地缓存 4.新增canvas.video.audio等新标签元素,新增特殊内容元 ...