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

     

     

     

  • 相关阅读:
    Redis Hashes 巧用sort排序
    Redis 压缩存储的配置
    计算
    关于时间大小判断的坑和网上工具类的看法
    Mysql中字段类型之时间戳大坑2
    Mysql中字段类型之时间戳大坑
    Spring和springmvc父子容器注解扫描问题详解
    JXL导出Excel工具类
    Maven学习
    MySQL之账户管理
  • 原文地址:https://www.cnblogs.com/my-program-life/p/11592838.html
Copyright © 2011-2022 走看看