使用idea快速创建SpringBoot项目

快速创建SpringBoot项目

 

 

 

 

 

 

 编写MyController类

@RestController
public class MyController {
    @RequestMapping("/hello")
    public String print(){
        return "Hello SpringBoot!";
    }
}
知识兔

运行项目

启动Spring Boot出现警告

WARN 6428 --- [ restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)

原因分析:
templates 文件夹下没有html,jsp或者ftl文件
application.properties配置文件为:

spring.thymeleaf.check-template=true
spring.thymeleaf.check-template-location=true
知识兔

它会去扫描你的templates文件夹下是否有html,jsp或者ftl文件,如果没有就会报出警告
此警告可以不处理,对程序运行无影响
处理方法:将true改为false

spring.thymeleaf.check-template=false
spring.thymeleaf.check-template-location=false
知识兔

 

在浏览器打开:

SpringBoot的热部署:

对SpringBoot项目进行热部署后,当修改代码时,不再需要每次重新启动SpringBoot,只需要在浏览器刷新即可。

 在pom.xml中导入

     <!--热部署配置-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
知识兔

 在Settings中搜索Compiler

 

 

 

计算机