spring boot 部署、启动

1、热部署

         1)CTRL + SHIFT+ A --> 查找make project automatically --> 选中

         2)CTRL + SHIFT+ A --> 查找Registry --> 找到并勾选

compiler.automake.allow.when.app.running

         3)重启IDEA

         4)maven添加依赖

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <optional>true</optional>
</dependency>

         5)开启热部署

<plugin>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-maven-plugin</artifactId>
   <!-- 开启热部署 -->
   <configuration>
      <fork>true</fork>
   </configuration>
</plugin>

         6)热部署原理

                   a、classloader1加载不变类

                   b、classloader2加载会改动的类

                   c、代码有改动,触发classloader2重新加载

2、启动方式

      1)IDEA中运行/调试

Application的main方法

      2)控制台

进入项目路径,输入命令:mvn spring-boot:run

      3)打成jar包

                   a、打包命令:mvninstall 或 mvn clean package

b、运行命令:java –jar demo.jar

      4)打成war包

                   a、打包命令:mvninstall 或 mvn clean package

                   b、部署到tomcat上

         注:打war包需移除springboot自带tomcat

         方式一:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-tomcat</artifactId>
   <scope>provided</scope>
</dependency>

         方式二:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
   <!-- 移除嵌入式tomcat插件 -->
   <exclusions>
      <exclusion>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
      </exclusion>
   </exclusions>
</dependency>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值