A ResourcePool could not acquire a resource from its primary factory or source

前端 未结 5 1378
清歌不尽
清歌不尽 2020-12-16 17:17

I\'m trying to connect to a database in Java, using jdbcTemplate and I\'m gettin the error below. I have Googled for a long time and all solutions I found didn\'t solve my p

5条回答
  •  一向
    一向 (楼主)
    2020-12-16 17:48

    This message can also be displayed, if, like me, you run your application with the Maven plugin for Tomcat:

    mvn clean install tomcat7:run
    

    and you have a provided scope element in your Maven dependency:

    
      mysql
      mysql-connector-java
      5.1.36
      provided
    
    

    The provided scope will prevent the connector from being part of the war archive and the Tomcat plugin will find no connector to establish the database connection.

    Simply removing the provided scope from the dependency solves the issue.

提交回复
热议问题