【springboot】之将properties配置转为bean

将springboot里面非application.yml 或者application.properties 里面的key-value转为JavaBean

/**
 * @Describe: DataSource Bean
 * @Author: Hubal in 2018/2/22
 **/
@Configuration
@ConfigurationProperties(prefix = "druid")
@PropertySource(value = "classpath:config/druid.properties")
@Data
@Component
public class DruidBean {

    private int initialSize;
    private int minIdle;
    private int maxActive;
    private long maxWait;
    private long timeBetweenEvictionRunsMillis;//
    private long minEvictableIdleTimeMillis;//配置连接在池子中最小生存时间
    private String validationQuery;//检验SQL
    private Boolean testWhileIdle;
    private Boolean testOnBorrow;
    private Boolean testOnReturn;
    private Boolean poolPreparedStatements;
    private int maxPoolPreparedStatementPerConnectionSize;
    private String filters;
    private String connectionProperties;
    private Boolean useGlobalDataSourceStat;

}
原文地址:https://www.cnblogs.com/gyjx2016/p/8569252.html