springBoot2.x啟動項目報java.sql.SQLNonTransientConnectionException


將項目從springBoot1.x升級到springBoot2.x,啟動報錯:

1 java.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near ';characterEncoding=UTF8&useSSL=true?autoReconnect=true'.
2     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
3     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
4     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
5     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
6     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
7     at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:79)
8     at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:131)
9     at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)

看提示報錯原因是mysql的jdbc連接字符串不符合要求

修改成前面文章的url:MySQL的JDBC驅動(8.0版本)

1 jdbc:mysql://{ip}:{port}/{db}?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true

 再次啟動,還是報錯,看到有錯誤提示:

1 Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

很明顯是jdbc驅動包沒配對,修改之,再次啟動成功

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM