我正在使用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.
答案 0 :(得分:0)
将属性spring.datasource.jdbc-url
更改为
spring.datasource.url=jdbc:mysql//localhost:3306/reserving?autoReconnect=true&useSSL=false
答案 1 :(得分:0)
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