zoukankan      html  css  js  c++  java
  • 使用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

     

     

     

  • 相关阅读:
    使用Powershell开机启动隐藏窗口的程序
    使用鼠标左键事件实现VR中的Eye Gaze Input
    在github网站上更新fork的repo
    零Web知识个性化Blog
    C#中的Attribute
    ConsoleWindow中的双击日志定位
    Hackintosh Issues 10.13.x
    开启macOS的原生写入Ntfs的功能
    Install macOS High Sierra on Any Supported Intel-based PC
    DSDT/SSDT
  • 原文地址:https://www.cnblogs.com/my-program-life/p/11592838.html
Copyright © 2011-2022 走看看