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 ...
随机推荐
- Linux虚拟机扩展磁盘
Linux虚拟机扩展磁盘 1.虚拟机关机,Vmware中扩展磁盘 2.虚拟机开机,查看磁盘大小 [root@hadoop6 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 devtmp ...
- Kafka之--多zookeeper,多broker之搭建
闲来如事,突发兴趣倒腾一下了kafka.其实类似环境搭建的博客很多,我这里算是整合一下,另外写出自己的过程与看法.完整的过程如下: 1)先准备好3台服务器.我准备的机器hostname/ip为: ka ...
- Guava - 字符串处理
Joiner 连接 比如,有这样一个集合[1,2,3,4,5,7,null],想把这个集合转换成以#分割的字符串,并过滤掉集合中的空元素 List<Integer> eleList = A ...
- 14Java进阶网络编程API
1.网络协议的三要素:语义.语法和时序 语义表示要做什么,语法表示要怎么做,时序表示做的顺序. 2.网络OSI七层模型 OSI/RM 模型(Open System Interconnection/Re ...
- vue知识点---element el-date-picker 插件默认时间属性default-value怎么赋值?
参考网址: http://www.imooc.com/wenda/detail/509359 默认值,你放到 v-model里面就好. v-model="time" data(){ ...
- Thinkphp中取消url中的index.php 和 Home 默认模块
将配置文件中改: <?phpreturn array( //'配置项'=>'配置值' 'URL_MODEL'=>'2', //去掉url中index.php ' ...
- springboot 中 inputStream 神秘消失之谜
序言 最近小明接手了前同事的代码,意料之外.情理之中的遇到了坑. 为了避免掉入同一个坑两次,小明决定把这个坑记下来,并在坑前立一个大牌子,避免其他小伙伴掉进去. HTTPClient 模拟调用 为了把 ...
- 干了六年Android开发现在裸辞失业了,再过2个月就30了,该怎么继续生活?
这是我在某论坛看到别人分享的故事,觉得可以展开聊一下,对于我们这些中年程序员,可以裸辞吗? 前言 首先介绍一下主人公的情况.目前所在的是一家小的创业公司,待了3年多,薪资一般吧,之前在一家中型上市企业 ...
- CentOS帮助类语法
目录 一.man获取帮助信息 二.help获得shell内置命令的帮助信息 三.history查看所有命令历史 补充:Linux常用快捷键 一.man获取帮助信息 基本语法:man [命令或配置文件] ...
- 基于Java和Bytemd用120行代码实现一个桌面版Markdown编辑器
前提 某一天点开掘金的写作界面的时候,发现了内置Markdown编辑器有一个Github的图标,点进去就是一个开源的Markdown编辑器项目bytemd(https://github.com/byt ...