application常用配置

YML文件语法

1,有层级结构(缩进)

2采用key: value  :号之后加空格

 

一.端口,项目上下文根

server:
  port: 8080
  servlet:
    context-path: /levenx

 


二.关系型数据库

1.mysql

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/levenx?useUnicode=true&characterEncoding=UTF-8&useSSL=false
    username: root
    password: password
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true

 


三.nosql数据库

1.redis

spring:
  redis:
    database: 0
    host: localhost
    port: 6379
    password:
    jedis:
      pool:
        max-active: 8
        max-wait: -1
        max-idle: 8
        min-idle: 0
    timeout: 0

 


四.levenx工具包

levenx:
  is-build: true
  entity:
    - name: goodSound
      field:
        - name: String

 


五.JavaMail

  #mail
  mail:
    host: smtp.163.com
    username: levenx2018@163.com
    password: xxxxxxx(163邮箱的授权码)
    properties:
      mail:
        smtp:
          auth: true

 六.示例

server:
  port: 8090
  servlet:
    context-path: /
spring:
  datasource:
    #引入druid数据源
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.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

mybatis:
  type-aliases-package: com.jt.demo.pojo
  mapper-locations: classpath:/mybatis/mappers/*.xml
  #开启驼峰映射
  configuration:
    map-underscore-to-camel-case: true

 

posted @ 2019-09-11 10:38  B1ack_Wall  阅读(1083)  评论(0编辑  收藏  举报