Spring Boot 要点--启动类和热部署

时间:2021-08-22 22:47:12

  spring boot需要一个启动类 比如

package com.tianmaying;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan; @SpringBootApplication
@ServletComponentScan
public class BlogApplication { public static void main(String[] args) throws Exception {
SpringApplication.run(BlogApplication.class, args);
} }

Servlet类所在的包路径必须是BlogApplication所在的包路径的子路径才能被扫描到,否则需要通过basePackages属性指定Servlet类所在的包。

2、让Spring Boot项目支持热部署,在maven配置文件添加如下依赖:

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