• 强国博客首页整合公告 2019-06-08
  • 西海都市报数字报刊平台 2019-05-27
  • 美国反拥枪的孩子很受伤 2019-05-25
  • C罗戴帽单骑救主 葡萄牙33战平西班牙 2019-05-25
  • 证监会去年对外公开监管信息14560条 2019-05-16
  • 中山八路总站调整12公交线 2019-05-16
  • 谢春涛:深刻把握“中国特色社会主义进入新时代”的重大意义 2019-05-09
  • 湖南一博士生举报水利局领导受贿 遭到冒牌纪委约谈 2019-05-09
  • 西安地铁唐风诗韵文化专列将于6月18日首发 2019-04-30
  • 铜梁区旧县街道:全面提升执行力 推动工作落地见效 2019-04-30
  • 上海电影节女性影人大放异彩 中生代女演员不用焦虑 2019-04-29
  • 龙永图力挺制造业 密集型产业不能丢 2019-04-29
  • 云冈石窟掌门人张焯入围“绿色中国年度人物”复评 2019-04-24
  • 网传上海限购政策松绑 市房管局目前调控政策并无变化 2019-04-23
  • 新疆坚决打好污染防治攻坚战 2019-04-23
  • springboot+druid+mybatis+mysql启动报错,请高手帮助

    关注 发布于 03/16 17:18
    阅读 197
    收藏 0

    广东十一选五推荐号 www.qhysp.com spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
    spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xx?serverTimezone=utc&characterEncoding=utf8&useUnicode=true&useSSL=false
    spring.datasource.username=xxx
    spring.datasource.password=xxx
    spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
    spring.datasource.initialSize=5
    spring.datasource.minIdle=5
    spring.datasource.maxActive=20
    spring.datasource.maxWait=60000
    spring.datasource.filters=stat,wall
    spring.datasource.timeBetweenEvictionRunsMillis=60000
    spring.datasource.minEvictableIdleTimeMillis=300000
    spring.datasource.validationQuery=select 'x'
    spring.datasource.testWhileIdle=true
    spring.datasource.testOnBorrow=false
    spring.datasource.testOnReturn=false
    spring.datasource.poolPreparedStatements=true
    spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
    spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
    spring.druidLoginName=admin
    spring.druidPassword=admin

     

    @Bean
        public SqlSessionFactoryBean sqlSessionFactory(DruidDataSource datasource){
            SqlSessionFactoryBean bean=new SqlSessionFactoryBean();
            datasource.setInitialSize(initialSize);
            datasource.setMinIdle(minIdle);
            datasource.setMaxActive(maxActive);
            datasource.setMaxWait(maxWait);
            datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);    
            datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);    
            datasource.setValidationQuery(validationQuery);
            datasource.setTestWhileIdle(testWhileIdle);
            datasource.setTestOnBorrow(testOnBorrow);
            datasource.setTestOnReturn(testOnReturn);   
            datasource.setPoolPreparedStatements(poolPreparedStatements);    
            datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);    
            try {
                datasource.setFilters(filters);
            } catch (SQLException e) {
                e.printStackTrace();
            }
            datasource.setConnectionProperties(connectionProperties);
            bean.setDataSource(datasource);
            return bean;
        }
        
        @Bean
        public SqlSessionTemplate sqlSession(SqlSessionFactoryBean sqlSessionFactory){
            SqlSessionTemplate bean=null;
            try {
                bean = new SqlSessionTemplate(sqlSessionFactory.getObject());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return bean;
        }

     

    报错如下:

    [2019-03-16 17:14:38] ERROR org.springframework.boot.SpringApplication - Application run failed
    java.util.ConcurrentModificationException: null
        at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:719)
        at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:742)
        at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:810)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
        at net.hb.xuelebaoapp.config.MainApplication.main(MainApplication.java:19)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
    [2019-03-16 17:14:38] INFO  org.apache.catalina.loader.WebappClassLoaderBase - Illegal access: this web application instance has been stopped already. Could not load [com.mysql.jdbc.MySQLConnection]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
    java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [com.mysql.jdbc.MySQLConnection]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1363)
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1351)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:820)
        at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.findClassIgnoringNotFound(TomcatEmbeddedWebappClassLoader.java:121)
        at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.doLoadClass(TomcatEmbeddedWebappClassLoader.java:86)
        at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass(TomcatEmbeddedWebappClassLoader.java:68)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1173)
        at com.alibaba.druid.util.Utils.loadClass(Utils.java:220)
        at com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker.<init>(MySqlValidConnectionChecker.java:50)
        at com.alibaba.druid.pool.DruidDataSource.initValidConnectionChecker(DruidDataSource.java:1231)
        at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:885)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1300)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1296)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:109)
        at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
        at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
        at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
        at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:82)
        at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:68)
        at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:338)
        at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84)
        at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
        at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326)
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
        at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:108)
        at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
        at com.sun.proxy.$Proxy96.query(Unknown Source)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:136)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
        at com.sun.proxy.$Proxy93.selectList(Unknown Source)
        at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:222)
        at net.hb.xuelebaoapp.system.dao.impl.FredaDaoImpl.queryForList(FredaDaoImpl.java:105)
        at net.hb.xuelebaoapp.manager.sys.service.impl.ParamServiceImpl.list(ParamServiceImpl.java:41)
        at net.hb.xuelebaoapp.system.listener.SystemInitListener$launchSPMonitor.run(SystemInitListener.java:82)
        at java.lang.Thread.run(Thread.java:748)
    [2019-03-16 17:14:39] INFO  com.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited
    [2019-03-16 17:14:39] INFO  com.alibaba.druid.pool.DruidDataSource - {dataSource-1} closed

     

    通过换mysql驱动包和druid驱动包版本,试了都不行

    加载中
    0
    w
    wailouci
    列表循环中增减元素了?
    0
    关注
    关注

    什么意思??

    0
    关注
    关注

    请大神帮助看看

    返回顶部
    顶部
  • 强国博客首页整合公告 2019-06-08
  • 西海都市报数字报刊平台 2019-05-27
  • 美国反拥枪的孩子很受伤 2019-05-25
  • C罗戴帽单骑救主 葡萄牙33战平西班牙 2019-05-25
  • 证监会去年对外公开监管信息14560条 2019-05-16
  • 中山八路总站调整12公交线 2019-05-16
  • 谢春涛:深刻把握“中国特色社会主义进入新时代”的重大意义 2019-05-09
  • 湖南一博士生举报水利局领导受贿 遭到冒牌纪委约谈 2019-05-09
  • 西安地铁唐风诗韵文化专列将于6月18日首发 2019-04-30
  • 铜梁区旧县街道:全面提升执行力 推动工作落地见效 2019-04-30
  • 上海电影节女性影人大放异彩 中生代女演员不用焦虑 2019-04-29
  • 龙永图力挺制造业 密集型产业不能丢 2019-04-29
  • 云冈石窟掌门人张焯入围“绿色中国年度人物”复评 2019-04-24
  • 网传上海限购政策松绑 市房管局目前调控政策并无变化 2019-04-23
  • 新疆坚决打好污染防治攻坚战 2019-04-23