spring boot应用常用配置
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应用常用配置的更多相关文章
- spring boot 简要常用配置
# 激活开发环境 spring.profiles.active=dev spring.mvc.date-format=yyyy-MM-dd HH:mm:ss spring.http.encoding. ...
- Spring Boot 2.0 配置图文教程
摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠BYSocket 」欢迎关注和转载,保留摘要,谢谢! 本章内容 自定义属性快速入门 外化配置 自动配置 自定义创建 ...
- spring boot中常用的配置文件的重写
@Configuration public class viewConfigSolver extends WebMvcConfigurerAdapter { /* spring boot 已经自动配置 ...
- spring boot日志管理配置
spring Boot在所有内部日志中使用Commons Logging,但是默认配置也提供了对常用日志的支持,如:Java Util Logging,Log4J,Log4J2和Logback.每种L ...
- Spring Boot 外部化配置(一)- Environment、ConfigFileApplicationListener
目录 前言 1.起源 2.外部化配置的资源类型 3.外部化配置的核心 3.1 Environment 3.1.1.ConfigFileApplicationListener 3.1.2.关联 Spri ...
- spring boot web相关配置
spring boot集成了servlet容器,当我们在pom文件中增加spring-boot-starter-web的maven依赖时,不做任何web相关的配置便能提供web服务,这还得归于spri ...
- 初识Spring Boot框架(二)之DIY一个Spring Boot的自动配置
在上篇博客初识Spring Boot框架中我们初步见识了SpringBoot的方便之处,很多小伙伴可能也会好奇这个Spring Boot是怎么实现自动配置的,那么今天我就带小伙伴我们自己来实现一个简单 ...
- Spring boot 的自动配置
Xml 配置文件 日志 Spring Boot对各种日志框架都做了支持,我们可以通过配置来修改默认的日志的配置: #设置日志级别 logging.level.org.springframework=D ...
- spring boot多数据源配置(mysql,redis,mongodb)实战
使用Spring Boot Starter提升效率 虽然不同的starter实现起来各有差异,但是他们基本上都会使用到两个相同的内容:ConfigurationProperties和AutoConfi ...
随机推荐
- CentOS7.9安装Oracle 12C数据库实战
准备工作(先安装好以下软件): 1.服务器操作系统 CentOS7.9 2.Shell工具:Xshell 7免费版 3.Xmanager 7软件 =========================== ...
- 第五篇 -- git基础教程
git(权威指南)基础教程第一章 git -- gitbash -- cygwin git service:gitolite 两个的目录不同 gitbash ~ windows/home/admini ...
- document.all("div).style.display = "none"与 等于""的区别
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- SpringCloud升级之路2020.0.x版-4.maven依赖回顾以及项目框架结构
本系列代码地址:https://github.com/HashZhang/spring-cloud-scaffold/tree/master/spring-cloud-iiford 我们先来回顾下 m ...
- Python: 解析crontab正则,增加+操作
以下是使用Python解析crontab时间格式的一个类, 同时minute和hour支持了 + 的操作. 记录一下备忘. 其中的line参数是字符串分拆后的格式, 包含了 "week&qu ...
- 【PTA|Python】浙大版《Python 程序设计》题目集:第二章
前言 Hello!小伙伴! 非常感谢您阅读海轰的文章,倘若文中有错误的地方,欢迎您指出- 自我介绍 ଘ(੭ˊᵕˋ)੭ 昵称:海轰 标签:程序猿|C++选手|学生 简介:因C语言结识编程,随后转入计 ...
- (1)用 if语句 区间判断
/*此例子只做比喻演示*/ 1 #include <stdio.h> 2 int main() 3 { 4 5 int p; 6 scanf("%d",&p); ...
- 基于Java和Bytemd用120行代码实现一个桌面版Markdown编辑器
前提 某一天点开掘金的写作界面的时候,发现了内置Markdown编辑器有一个Github的图标,点进去就是一个开源的Markdown编辑器项目bytemd(https://github.com/byt ...
- docker-02
环境准备 10.0.0.100这台宿主机先做好给docker容器本地yum源,其实也可以用阿里等其他的yum源 1 上传6.9和7.6的镜像到10.0.0.100这台服务器 [root@docker ...
- Java ArrayList【笔记】
Java ArrayList[笔记] ArrayList ArrayList基本结构 ArrayList 整体架构比较简单,就是一个数组结构 源码中的基本概念 index 表示数组的下标,从 0 开始 ...