使用IDEA快速创建Spring Boot项目


快速创建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

 

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM