搭建本地环境,跑程序时遇到mysql连接不上
以下问题:
1.Exception in thread “main” org.springframework.beans.factory.BeanCreationExcepti
2.Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2983)
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1873)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1802)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265)
解决:发现mysql的jar包版本不对,并且mysql 8以上版本
异常错误: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.
这个问题是 使用了新的mysql驱动包,但驱动声明不是最新的: