application.xml定义的常量

2017-12-17  本文已影响0人  墨色尘埃

application.xml中定义的常量,在java类中不能再定义为static,否则根本取不到值。
在java类中使用

    @Value("${pName}")
    private String pName;

    @Value("${modelName}")
    private String modelName;

    @Value("${isForTest}")
    private boolean isForTest;

application.yml

mybatis:
  configuration:
    mapUnderscoreToCamelCase: true
    logImpl: org.apache.ibatis.logging.stdout.StdOutImpl
    typeAliasesPackage: com.jsptpd.gayg.modules
  mapperLocations: classpath:com/jsptpd/gayg/**/*.xml

spring:
  resource: 
    static-locations: file:/public/
  http:
    multipart:
      max-file-size: 20Mb
      max-request-size: 80Mb
  profiles:
    active: dev

application-dev.yml


server:
  port: 10002

spring:
  resource:
    static-locations: file:/public/
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql://172.16.11.66:3306/guian?useUnicode=true&characterEncoding=UTF-8
    username: root
    password: jsptpd
    driver-class-name: com.mysql.jdbc.Driver
    initialSize: 5
    minIdle: 5
    maxActive: 20
    maxWait: 60000
    #自动检测关闭和空闲连接的间隔
    timeBetweenEvictionRunsMillis: 30000
    #最小生存时间
    minEvictableIdleTimeMillis: 300000
    validationQuery: SELECT 1 FROM DUAL
    testWhileIdle: true
    #这个参数设置为true,可以保证每次的连接都是正常的,但是。。 性能会降低, 建议使用空闲下检测30s一次, 这样服务器最多30s出现问题后恢复
    testOnBorrow: false
    testOnReturn: false
    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=3000
    filters: stat
    #PSCatch
    poolPreparedStatements: true
    maxPoolPreparedStatementPerConnectionSize: 20

# 包名
pName: com.jsptpd.gayg.modules.business.dao.
# 包名
modelName: com.jsptpd.gayg.modules.business.model.


# 标记是否用于测试
isForTest: true
上一篇下一篇

猜你喜欢

热点阅读