使用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