![](/img/trans.png)
[英]Facing “com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections”. java error while inserting"
[英]What does the error message “com.mysql.cj.exceptions.WrongArgumentException: The database URL cannot be null.” mean?
我正在使用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.
將屬性spring.datasource.jdbc-url
更改為
spring.datasource.url=jdbc:mysql//localhost:3306/reserving?autoReconnect=true&useSSL=false
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.