Spring Boot应用程序的URL不能为空 [英] Spring Boot application The url cannot be null

查看:1327
本文介绍了Spring Boot应用程序的URL不能为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,当我尝试启动Spring Boot应用程序时获得堆栈跟踪

Hello when i trying start Spring Boot app a get a stacktrace

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中添加了网址

I added url in application.properties

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

我认为oracle的驱动程序可能有问题,maven找不到此依赖项

I think it's may be problem with drivers to oracle, maven can't find this dependency

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

所以我只是将外部jar添加到我的项目中,但是我仍然遇到网址错误的问题

So I just add external jar to my project, but i still have problem with wrong url

推荐答案

Not loading a JDBC driver as driverClassName property is null.

您可能还想通过在属性文件中添加驱动程序类名称来解决此问题:

You might also want to resolve that by adding a driver class name to your properties file:

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

您是否在应用程序中的某个位置配置了DataSource bean?假设您尚未禁用自动配置,则应该能够获得有效的数据源配置.

Are you configuring a DataSource bean somewhere within your application? Assuming you haven't disabled auto configuration you should be able to get a valid datasource configuration.

这篇关于Spring Boot应用程序的URL不能为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆