【问题标题】:URL must start with 'jdbc' in sprinboot在 Spring Boot 中,URL 必须以“jdbc”开头
【发布时间】:2018-09-22 16:18:31
【问题描述】:

我的应用程序正在运行,但出现应用程序错误。我尝试了几次同样的事情发生。我检查了数据库连接,一切都很好。这些是我的日志

例外


Caused by: java.lang.IllegalArgumentException: URL must start with 'jdbc'
at org.springframework.util.Assert.isTrue(Assert.java:116) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.jdbc.DatabaseDriver.fromJdbcUrl(DatabaseDriver.java:268) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:230) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:176) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:43) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:81) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_161]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_161]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
... 40 common frames omitted

application.properties


#======================
# DATA SOURCE
#=====================

spring.datasource.url="jdbc:mysql://localhost:3306/customerdb?useSSL=false"
spring.datasource.username=root
spring.datasource.password=root
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.dbcp2.test-while-idle=true
spring.datasource.dbcp2.validation-query= SELECT 1


#============================
# JPA/Hibernate
#===========================
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy

#===================================================================
# Spring Security / Queries for AuthenticationManagerBuilder
#===================================================================
spring.queries.users-query=select email,password active form user where email=?
spring.queries.roles-query=select u.email, r.role from user u inner join user_role ur on(u.user_id=ur.user_id) inner join role r on(ur.role_id=r.role_id) where u.email=?

# ===============================
# Thymeleaf configurations
# ===============================
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false

#====================================
#LOGGING
#====================================
logging.level.root=warn
logging.level.org.org.springframework.web=debug
logging.level.org.org.Hibernate=error

【问题讨论】:

  • 尝试删除引号,因为它似乎是它们的唯一行
  • 感谢@dimwittedanimal
  • 请随意接受 Elarbi 的回答,因为它和我的回答一样。

标签: java spring spring-boot spring-data datasource


【解决方案1】:

替换这个:

spring.datasource.url="jdbc:mysql://localhost:3306/customerdb?useSSL=false"

有了这个:

spring.datasource.url=jdbc:mysql://localhost:3306/customerdb?useSSL=false

【讨论】:

猜你喜欢
  • 2021-03-09
  • 2020-10-31
  • 2019-10-22
  • 1970-01-01
  • 2016-04-05
  • 2023-02-05
  • 2015-02-15
  • 2019-06-29
  • 1970-01-01
相关资源
最近更新 更多