【问题标题】:What does the error message "com.mysql.cj.exceptions.WrongArgumentException: The database URL cannot be null." mean?错误信息“com.mysql.cj.exceptions.WrongArgumentException:数据库 URL 不能为空”是什么意思。意思是?
【发布时间】:2019-12-06 01:00:13
【问题描述】:

我正在使用 MySQL 数据库开发 Spring Boot 项目。如果我运行我的代码,WrongArgumentException 表示databaseURL cannot be null

application.properties:

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.jdbc-url=jdbc:mysql//localhost:3306/reserving?autoReconnect=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=****

##Mapper Config##
mybatis.type-aliases-package=com.springboot.reserving
mybatis.mapper-locations=mapper/**/*.xml

spring.devtools.livereload.enabled =true

spring.freemarker.cache=false

错误信息:

java.sql.SQLNonTransientConnectionException: Cannot load connection class
 because of underlying exception: 
com.mysql.cj.exceptions.WrongArgumentException: The database URL cannot be null.

【问题讨论】:

    标签: java mysql maven spring-boot


    【解决方案1】:

    将属性 spring.datasource.jdbc-url 更改为

    spring.datasource.url=jdbc:mysql//localhost:3306/reserving?autoReconnect=true&useSSL=false
    

    【讨论】:

      【解决方案2】:

      application-properties 中没有名为 spring.datasource.jdbc-url 的属性

      改变

      spring.datasource.jdbc-url
      

      spring.datasource.url
      

      spring.datasource.platform=mysql
      spring.datasource.url=jdbc:mysql//localhost:3306/reserving?autoReconnect=true&useSSL=false 
      spring.datasource.username=root
      spring.datasource.password=****
      spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
      spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-12-18
        • 1970-01-01
        • 1970-01-01
        • 2011-01-08
        • 1970-01-01
        • 2012-10-01
        • 1970-01-01
        相关资源
        最近更新 更多