亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

spring boot 配置druid

發布時間:2020-05-26 00:23:54 來源:網絡 閱讀:1275 作者:乾坤刀 欄目:軟件技術

application.yaml

spring:
  main:
    banner-mode: console
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql://localhost:3306/test
    username: test
    password: 123456
#    driver-class-name: com.mysql.jdbc.Driver
#    druid pool customize configuration
    driverClassName: com.mysql.jdbc.Driver
    initialSize: 10
    minIdle: 5
    maxActive: 20
    maxWait: 60000
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: select 1 from dual
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    removeAbandoned: true
    removeAbandonedTimeout: 1800
    logAbandoned: true
    filters: stat,wall,slf4j
    logSlowSql: true
    loginUsername: test
    loginPassword: 123456
          jdbc:
    template:
      max-rows: 1000
      query-timeout: 1200
  jpa:
    hibernate:
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
logging:
  level:
    root: debug

DruidConfiguration

@Component
@ConfigurationProperties(prefix = "spring.datasource")
public class DruidConfiguration {
    private String url;
    private String username;
    private String password;
    private String driverClassName;
    private int initialSize;
    private int minIdle;
    private int maxActive;
    private int maxWait;
    private int timeBetweenEvictionRunsMillis;
    private int minEvictableIdleTimeMillis;
    private String validationQuery;
    private boolean testWhileIdle;
    private boolean testOnBorrow;
    private boolean testOnReturn;
    private boolean removeAbandoned;
    private int removeAbandonedTimeout;
    private boolean logAbandoned;
    private String filters;
    private boolean logSlowSql;
    private String loginUsername;
    private String loginPassword;
}

@Configuration配置

@Configuration
public class CustomizeConfig {

    private final static Logger LOGGER = LoggerFactory.getLogger(CustomizeConfig.class);

    @Autowired
    private DruidConfiguration druidConfiguration;

        @Bean
    public DataSource druidDataSource(){
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(druidConfiguration.getUrl());
        datasource.setUsername(druidConfiguration.getUsername());
        datasource.setPassword(druidConfiguration.getPassword());
        datasource.setDriverClassName(druidConfiguration.getDriverClassName());
        datasource.setInitialSize(druidConfiguration.getInitialSize());
        datasource.setMinIdle(druidConfiguration.getMinIdle());
                datasource.setMaxActive(druidConfiguration.getMaxActive());
        datasource.setMaxWait(druidConfiguration.getMaxWait());
        datasource.setTimeBetweenEvictionRunsMillis(druidConfiguration.getTimeBetweenEvictionRunsMillis());
        datasource.setMinEvictableIdleTimeMillis(druidConfiguration.getMinEvictableIdleTimeMillis());
        datasource.setValidationQuery(druidConfiguration.getValidationQuery());
        datasource.setTestWhileIdle(druidConfiguration.isTestWhileIdle());
        datasource.setTestOnBorrow(druidConfiguration.isTestOnBorrow());
        datasource.setTestOnReturn(druidConfiguration.isTestOnReturn());
        datasource.setRemoveAbandoned(druidConfiguration.isRemoveAbandoned());
        datasource.setRemoveAbandonedTimeout(druidConfiguration.getRemoveAbandonedTimeout());
        datasource.setLogAbandoned(druidConfiguration.isLogAbandoned());
            try {
            datasource.setFilters(druidConfiguration.getFilters());
        } catch (SQLException e) {
            LOGGER.error("datasource.setFilters occur error.", e);
        }
        return datasource;
    }

      @Bean
    public ServletRegistrationBean druidServlet() {
        ServletRegistrationBean reg = new ServletRegistrationBean();
        reg.setServlet(new StatViewServlet());
        reg.addUrlMappings("/druid/*");
        reg.addInitParameter("loginUsername", druidConfiguration.getLoginUsername());
        reg.addInitParameter("loginPassword", druidConfiguration.getLoginPassword());
        reg.addInitParameter("logSlowSql", String.valueOf(druidConfiguration.isLogSlowSql()));
        return reg;
    }

    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new WebStatFilter());
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
        filterRegistrationBean.addInitParameter("profileEnable", "true");
        return filterRegistrationBean;
    }
}
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

漳浦县| 通山县| 新蔡县| 宜兰市| 鄂托克旗| 大安市| 米脂县| 商南县| 古蔺县| 盐边县| 色达县| 偃师市| 五常市| 巴林右旗| 民勤县| 利辛县| 陆良县| 通河县| 绍兴市| 昌黎县| 淅川县| 宜宾市| 汉阴县| 务川| 库尔勒市| 泰兴市| 台前县| 临安市| 浙江省| 成安县| 晴隆县| 汨罗市| 内乡县| 新巴尔虎右旗| 绥棱县| 额尔古纳市| 瓦房店市| 离岛区| 大冶市| 乌恰县| 三明市|