springBoot使用一个全局的配置文件,配置文件的名称是固定的。
基本格式: key=value
对象形式,行内写法,数组形式书写时,注意之间的缩进,对空格的要求十分的高,是层级关系。
- yaml可以给实体类赋值:
- @component//注册bean
@configurationProperties作用:
将配置文件中配置的每一个属性的值,映射到这个组件中;
告诉springBoot将本类中的所有属性和配置文件中相关的配置进行绑定。
参数:prefix="xxx":将配置文件中的xxx下面的所有属性-对应jt项目的配置
server:
port: 8081
servlet:
context-path: /
spring:
datasource:
#引入druid数据源
#type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/jtdb?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true
username: root
password: root
mvc:
view:
prefix: /WEB-INF/views/
suffix: .jsp
#mybatis-plush配置
mybatis-plus:
type-aliases-package: com.jt.pojo
mapper-locations: classpath:/mybatis/mappers/*.xml
configuration:
map-underscore-to-camel-case: true
logging:
level:
com.jt.mapper: debug
db项目的配置
#server 配置
server:
port: 80
#Spring 资源整合
spring:
datasource:
url: jdbc:mysql:///dbsys?serverTimezone=GMT%2B8&characterEncoding=utf8
username: root
password: root
thymeleaf:
cache: false
prefix: classpath:/templates/pages/
suffix: .html
aop:
proxy-target-class: false #false表示系统底层会基于JDK方式为目标对象创建代理对象
task:
execution:
pool:
core-size: 3 #定义核心线程数,当池中线程没有达到这个值时,每来一个任务都会创建一个新的线程.
queue-capacity: 1 #当来了新的任务,核心线程都在忙,假如队列还没有满,则将任务先扔到队列
max-size: 256 #当核心线程数都在忙,任务队列也满了,再来新的任务在创建新的线程,最多可以创建多少个由这个参数决定
keep-alive: 60000 #当并发访问高峰期过后,有些线程可能会空闲下来,超出一定的时间,线程要被释放,这个时间的指定由这个参数决定
thread-name-prefix: cgb-db-thread- #为池中的线程起个名字的前缀
mybatis:
mapper-locations:
- classpath:/mapper/*/*.xml
management:
endpoints:
web:
exposure:
include:
- "*"
logging:
level:
com.cy: debug
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。