2016-11-17 130 views
0

您好,當我試圖啓動春季啓動應用程式中得到堆棧跟蹤春季啓動應用程序的URL不能爲空

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添加URL

spring.datasource.url=jdbc:oracle:thin:@localhost:1521:spring 

我認爲它可能是問題與司機到Oracle,行家都找不到這種依賴性

<dependency> 
    <groupId>com.oracle</groupId> 
    <artifactId>ojdbc14</artifactId> 
    <version>10.2.0.4.0</version> 
</dependency> 

所以我只是外部jar添加到我的項目,但我仍然有問題,錯誤的URL

+0

一個真的不能重現該問題與你提供的信息。嘗試一個最小的測試例子。 – eis

回答

1
Not loading a JDBC driver as driverClassName property is null. 

您可能還需要添加一個驅動程序類名的屬性來解決文件:

spring.datasource.driver-class-name=oracle.jdbc.OracleDriver 

你的應用程序中的某處配置一個DataSource豆?假設你沒有禁用自動配置,你應該能夠獲得有效的數據源配置。

+0

謝謝我添加,但我仍然這個相同的問題。我didin't有數據源豆,我只是用添加批註JPA POJO類我設置hibernate.ddl-AUTO =創造降,我希望它是enaugh創建數據庫 –

+0

嗯表。當你運行Spring Boot應用程序時,它肯定會選擇屬性文件?是否有任何其他屬性配置比你知道工作? –

+0

不,我不確定,我只是數據庫配置,但application.properties是在默認本地化 –

相關問題