Springboot无法使用SpringBoot 2.0.3获取getConnection(用户名,密码),但在1.5.3中可以正常工作

时间:2018-07-10 23:13:31

标签: spring-boot

如果我按如下方式更改pom.xml,则会得到以下异常,而在进行mvn安装的单元测试期间没有其他更改。

我不是直接打这个电话

HikariCP HikariDataSource:第131-136行

 /** {@inheritDoc} */
 @Override
 public Connection getConnection(String username, String password) throws SQLException
 {
    throw new SQLFeatureNotSupportedException();
 }

Pom片段

<parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
     <!-- <version>1.5.4.RELEASE</version> -->
     <version>2.0.3.RELEASE</version>
     <relativePath /> <!-- lookup parent from repository -->
</parent>

堆栈跟踪:

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:450) ~[spring-orm-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:378) ~[spring-tx-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.test.context.transaction.TransactionContext.startTransaction(TransactionContext.java:103) ~[spring-test-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethod(TransactionalTestExecutionListener.java:192) ~[spring-test-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:291) ~[spring-test-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    ...
Caused by: java.sql.SQLFeatureNotSupportedException: null
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:135) ~[HikariCP-3.1.0.jar:na]
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:35) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:106) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]

0 个答案:

没有答案