• SpringBoot1.5.10.RELEASE整合druid时,在druid monitor界面出现(*) property for user to setup


    接上篇随笔,配置druid之后出现的错误,解决方法如下:

     1   @Bean(destroyMethod = "close",initMethod = "init")
     2     @ConfigurationProperties(prefix = "spring.datasource")
     3     public DataSource druidDataSource() {
     4         DruidDataSource datasource = new DruidDataSource();
     5         datasource.setUrl(dbUrl);
     6         datasource.setUsername(username);
     7         datasource.setPassword(password);
     8         datasource.setDriverClassName(driverClassName);
     9         datasource.setInitialSize(initialSize);
    10         datasource.setMinIdle(minIdle);
    11         datasource.setMaxActive(maxActive);
    12         datasource.setMaxWait(maxWait);
    13         datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
    14         datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    15         datasource.setValidationQuery(validationQuery);
    16         datasource.setTestWhileIdle(testWhileIdle);
    17         datasource.setTestOnBorrow(testOnBorrow);
    18         datasource.setTestOnReturn(testOnReturn);
    19         try {
    20             datasource.setFilters(filters);
    21         } catch (SQLException e) {
    22             logger.error("druid configuration initialization filter", e);
    23         }
    24         return datasource;
    25     }

    添加红色字体代码即可,因为本人是使用mybatis,需要配置释放方法以及初始化方法,如果是jpa,就不会出现这个问题,只需要引入以下代码:

    1 <dependency>
    2 <groupId>org.springframework.boot</groupId>
    3 <artifactId>spring-boot-starter-data-jpa</artifactId>
    4 </dependency>
  • 相关阅读:
    JS中!=、==、!==、===的用法和区别
    Jquery判断Checkbox是否选中三种方法
    C# 信号量 学习
    redis学习资料
    Redis常用命令
    MySQL、HBase、ES的对比
    我对依赖注入,控制反转的理解
    net输出错误日志
    XmlExtensions帮助类
    DatetimeHelper类的编写
  • 原文地址:https://www.cnblogs.com/mYunYu/p/9914918.html
Copyright © 2020-2023  润新知