SpringBoot 作为当下开发项目中最流行的框架之一,备受公司的青睐。下面我将和大家如何对 SpringBoot 进行环境配置,下面是详情内容。
一、pom文件配置
org.springframework.boot spring-boot-starter-parent 2.2.2.RELEASE org.springframework.boot spring-boot-starter-web org.mybatis.spring.boot mybatis-spring-boot-starter 2.1.1 com.github.pagehelper pagehelper-spring-boot-starter 1.2.13 mysql mysql-connector-java com.mchange c3p0 0.9.5.5 org.springframework.boot spring-boot-starter-freemarker org.springframework.boot spring-boot-starter-thymeleaf org.springframework.boot spring-boot-starter-mail org.springframework.boot spring-boot-starter-aop org.springframework.boot spring-boot-starter-logging org.springframework.boot spring-boot-starter-tomcat provided org.apache.commons commons-lang3 io.springfox springfox-swagger2 2.9.2 io.springfox springfox-swagger-ui 2.9.2 org.springframework.boot spring-boot-devtools true org.springframework.boot spring-boot-starter-test org.springframework.boot spring-boot-starter-cache net.sf.ehcache ehcache springboot org.springframework.boot spring-boot-maven-plugin org.springframework.boot spring-boot-maven-plugin true 相关starter系列坐标参考:
二、yml文件配置
yml文件放在resources目录下
端口号 上下文路径
server:
port: 8989
servlet:
context-path: /mvc
数据源配置
spring:
datasource:
type: com.mchange.v2.c3p0.ComboPooledDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/hr
username: root
password: root
freemarker:
suffix: .ftl
content-type: text/html #响应格式
charset: UTF-8
template-loader-path: classpath:/views/
热部署配置
devtools:
restart:
enabled: true
# 设置重启的目录,添加目录的文件需要restart
additional-paths: src/main/java
# 解决项目自动重新编译后接口报404的问题
poll-interval: 3000
quiet-period: 1000
Ehcache缓存配置
cache:
ehcache:
config: classpath:ehcache.xml
mybatis 配置
mybatis:
#映射文件的存放路径
mapper-locations: classpath:/mappers/*.xml
type-aliases-package: com.xxxx.springboot.po
configuration:
## 下划线转驼峰配置
map-underscore-to-camel-case: true
pageHelper
pagehelper:
helper-dialect: mysql
显示dao 执行sql语句
logging:
level:
com:
xxxx:
dao: debug
三、SQL映射文件配置
sql映射文件路径在"resources/mappers/"下
四、ehcahe.xml 文件
配置在resources下
<cache
name="users"
eternal="false"
maxElementsInMemory="100"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="0"
timeToLiveSeconds="300"
memoryStoreEvictionPolicy="LRU"/>
到此本篇关于 SpringBoot 环境配置知识总结的文章就介绍到这了,想要了解更多相关 SpringBoot ,希望大家以后多多支持我们!