美文网首页
SpringBoot学习笔记(二)

SpringBoot学习笔记(二)

作者: 熙航君 | 来源:发表于2020-05-28 17:00 被阅读0次

    @JsonIgnore:隐藏返回值
    @JsonFormat(pattern="yyyy-mm-dd hh:mm:ss", locale="zh", timezone="GMT+8"):时间格式化
    @JsonInclude(JsonInclude.Include.NON_NULL):为空的返回值可忽略

    SpringBoot开发环境热部署

    1.首先引入相应的jar包

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <!-- optional=true, 依赖不会传递, 该项目依赖devtools;
        之后依赖boot项目的项目如果想要使用devtools, 需要重新引入 -->
        <optional>true</optional>
    </dependency>
    

    2.application.properties文件中配置属性

    #关闭缓存,即时刷新
    #spring.freemarker.cache=false
    spring.thymeleaf.cache=true
    
    #热部署生效
    spring.devtools.restart.enabled=true
    #设置重启的目录,添加那个目录的文件需要restart
    spring.devtools.restart.additional-paths=src/main/java
    

    SpringBoot资源文件属性配置

    资源文件中的属性配置与映射到实体类
    添加相关依赖

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    

    如果出现乱码问题,可以访问https://tool.chinaz.com/tools/unicode.aspx进行转码

    相关文章

      网友评论

          本文标题:SpringBoot学习笔记(二)

          本文链接:https://www.haomeiwen.com/subject/ofcaahtx.html