我正在使用 MySQL 數據庫開發一個 Spring Boot 項目。如果我運行我的代碼,一個WrongArgumentException說法是databaseURL cannot be null.application.properties:spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.datasource.jdbc-url=jdbc:mysql//localhost:3306/reserving?autoReconnect=true&useSSL=falsespring.datasource.username=rootspring.datasource.password=****##Mapper Config##mybatis.type-aliases-package=com.springboot.reservingmybatis.mapper-locations=mapper/**/*.xmlspring.devtools.livereload.enabled =truespring.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.
2 回答

三國紛爭
TA貢獻1804條經驗 獲得超7個贊
將屬性更改spring.datasource.jdbc-url
為
spring.datasource.url=jdbc:mysql//localhost:3306/reserving?autoReconnect=true&useSSL=false

HUH函數
TA貢獻1836條經驗 獲得超4個贊
應用程序屬性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
添加回答
舉報
0/150
提交
取消