你好,当我尝试启动Spring Boot应用程序时获取一个堆栈跟踪
2016-11-18 04:41:35.492 WARN 4256 --- [ restartedMain] o.a.tomcat.jdbc.pool.PooledConnection : Not loading a JDBC driver as driverClassName property is null.
2016-11-18 04:41:35.499 ERROR 4256 --- [ restartedMain] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
java.sql.SQLException: The url cannot be null
at java.sql.DriverManager.getConnection(DriverManager.java:649) ~[na:1.8.0_111]
at java.sql.DriverManager.getConnection(DriverManager.java:208) ~[na:1.8.0_111]
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:308) ~[tomcat-jdbc-8.5.4.jar:na]
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.4.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:716) [tomcat-jdbc-8.5.4.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:648) [tomcat-jdbc-8.5.4.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468) [tomcat-jdbc-8.5.4.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143) [tomcat-jdbc-8.5.4.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.4.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.4.jar:na]
我在application.properties
中添加了urlspring.datasource.url=jdbc:oracle:thin:@localhost:1521:spring
我认为对于oracle的驱动程序可能有问题,maven无法找到这种依赖
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
所以我只是将外部jar添加到我的项目中,但我仍然有错误的URL问题
答案 0 :(得分:1)
Not loading a JDBC driver as driverClassName property is null.
您可能还想通过向属性文件添加驱动程序类名来解决此问题:
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
您是在应用程序中的某个位置配置DataSource bean吗?假设您没有禁用自动配置,您应该能够获得有效的数据源配置。
答案 1 :(得分:0)
Oracle JDBC驱动程序只是V 11.2.0.4中maven的一部分..过去有一些问题。
点击链接&#34; https://blogs.oracle.com/dev2dev/entry/oracle_maven_repository_instructions_for&#34;下载并将您想要的驱动程序添加到本地maven仓库。