pom.xml

<!--自动打包-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> <!--热更新:ctrl+F9快速重启服务器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency> <!--postman使用内容协商,修改Header/Accept-->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency> <!--切换tomcat服务器为jetty-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency> <!--开启指标监控-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency> <!--thymeleaf模板中使用shiro标签-->
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>2.0.0</version>
</dependency>
<!--shiro整合springboot依赖-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-starter</artifactId>
<version>1.5.3</version>
</dependency>
<!--shiro缓存-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>1.5.3</version>
</dependency>

application.yml

# 不拦截resources目录下的静态资源请求,访问时必须加上前缀res:http://localhost:8080/res/bug.jpg
spring:
mvc:
static-path-pattern: /res/** # 默认访问路径:在资源目录下新建一个文件夹haha,将静态文件放到该文件夹下;访问时加上前缀res:http://localhost:8080/bug.jpg
resources:
static-locations: [classpath:/haha/] # 禁用所有静态资源访问
resources:
add-mappings: false # 浏览器中开启请求参数内容协商模式,响应给客户端json:http://localhost:8080/test?format=json
spring:
contentnegotiation:
favor-parameter: true # 设置请求前缀,请求方式:http://localhost:8080/world/login
server:
servlet:
context-path: /world # 配置thymeleaf模板
spring:
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
content-type: text/html
mode: HTML5 # 文件上传
# maxFileSize 是单个文件大小
# maxRequestSize 是设置总上传的数据大小
spring:
servlet:
multipart:
enabled: true
max-file-size: 10MB
max-request-size: 100MB # 配置数据源
spring:
datasource:
url: jdbc:mysql://localhost:3306/test?characterEncoding=utf8&useSSL=true&serverTimezone=UTC
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver # 指标监控,暴露所有端点信息,以web方式暴露;访问beans:http://localhost:8080/actuator/beans
management:
endpoints:
enabled-by-default: true
web:
exposure:
include: '*' # 指标监控,禁用所有,开启单个
management:
endpoints:
enabled-by-default: false
endpoint:
beans:
enabled: true
health:
enabled: true # 配置端口
server:
port: 80 # 视图解析
spring:
mvc:
view:
suffix: ".html" # 开启驼峰命名自动映射
mybatis:
configuration:
map-underscore-to-camel-case: true # 配置日志记录,top.yfly.sb是java和mapper中间的路径
logging:
level:
top:
yfly:
sb: debug

spring boot应用常用配置的更多相关文章

  1. spring boot 简要常用配置

    # 激活开发环境 spring.profiles.active=dev spring.mvc.date-format=yyyy-MM-dd HH:mm:ss spring.http.encoding. ...

  2. Spring Boot 2.0 配置图文教程

    摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠BYSocket 」欢迎关注和转载,保留摘要,谢谢! 本章内容 自定义属性快速入门 外化配置 自动配置 自定义创建 ...

  3. spring boot中常用的配置文件的重写

    @Configuration public class viewConfigSolver extends WebMvcConfigurerAdapter { /* spring boot 已经自动配置 ...

  4. spring boot日志管理配置

    spring Boot在所有内部日志中使用Commons Logging,但是默认配置也提供了对常用日志的支持,如:Java Util Logging,Log4J,Log4J2和Logback.每种L ...

  5. Spring Boot 外部化配置(一)- Environment、ConfigFileApplicationListener

    目录 前言 1.起源 2.外部化配置的资源类型 3.外部化配置的核心 3.1 Environment 3.1.1.ConfigFileApplicationListener 3.1.2.关联 Spri ...

  6. spring boot web相关配置

    spring boot集成了servlet容器,当我们在pom文件中增加spring-boot-starter-web的maven依赖时,不做任何web相关的配置便能提供web服务,这还得归于spri ...

  7. 初识Spring Boot框架(二)之DIY一个Spring Boot的自动配置

    在上篇博客初识Spring Boot框架中我们初步见识了SpringBoot的方便之处,很多小伙伴可能也会好奇这个Spring Boot是怎么实现自动配置的,那么今天我就带小伙伴我们自己来实现一个简单 ...

  8. Spring boot 的自动配置

    Xml 配置文件 日志 Spring Boot对各种日志框架都做了支持,我们可以通过配置来修改默认的日志的配置: #设置日志级别 logging.level.org.springframework=D ...

  9. spring boot多数据源配置(mysql,redis,mongodb)实战

    使用Spring Boot Starter提升效率 虽然不同的starter实现起来各有差异,但是他们基本上都会使用到两个相同的内容:ConfigurationProperties和AutoConfi ...

随机推荐

  1. 微信小程序云开发-列表下拉刷新

    一.json文件开启页面刷新 开启页面刷新.在页面的json文件里配置两处: "enablePullDownRefresh": true, //true代表开启页面下拉刷新 &qu ...

  2. ArcGis API JS 4.X本地化部署与地图的基础使用

    准备工作 首先下载ArcGIS API for JavaScript4.x,这里下载的是4.19. 官方下载地址:https://developers.arcgis.com/downloads/ ar ...

  3. 公有组件ShowCodeList实现原理之一一下拉框的实现

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. GlassFish 任意文件读取漏洞

    poc https://192.168.49.2:4848/theme/META-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0 ...

  5. icmp介绍以及arp攻击

    目录 一.ip数据包格式 二.ICMP协议介绍 三.ARP协议介绍 四.ARP攻击原理 一.ip数据包格式 网络层的功能: 定义了基于ip协议的逻辑地址 连接不同的媒介类型 选择是数据通过网络的最佳途 ...

  6. 内置函数 strlen

    1 //内置函数 strlen 2 //计算字符串的实际长度,不含字符串结束标准\0 3 4 #include<stdio.h> 5 #include<stdlib.h> 6 ...

  7. 字节跳动上传了一份“面试官版Android面试小册”,不讲一句废话,全是精华

    前言 金三银四马上就到了,很多粉丝朋友私信希望我出一篇面试专题或者分享面试相关的笔记来学习,这不今天就给大家安排上了?(都是干货,错过就是亏.) 下面的面试笔记都是精心整理好免费分享给大家的,希望新朋 ...

  8. 冲击BATZ!GitHub近8.3K+的Android进阶指南,面试再也不愁了

    过去十年是移动互联网蓬勃发展的黄金期,相信每个人也都享受到了移动互联网红利,在此期间,移动互联网经历了曙光期.成长期.成熟期.现在来说已经进入饱和期. 依然记得在 2010-2013 年期间,从事移动 ...

  9. Notes about WindowPadX

    WindowPadX乃一Autohotkey脚本,具有强大的单/多显示器窗口排布能力且易于配置.有了它,那些Pro版收费的.需要安装的DisplayFusion, MultiMon TaskBar, ...

  10. Java-ThreadPool线程池总结

    ThreadPool 线程池的优势 线程池做的工作主要是控制运行的线程数量,处理过程中将任务放入队列,然后在线程创建后启动这些任务,如果线程数量超过了最大数量,超出的线程排队等候,等待其他线程执行完毕 ...