1. 程式人生 > >創建spring boot 項目所遇到的問題

創建spring boot 項目所遇到的問題

conn 啟動 pri aso pre htm 遇到 driver 約束

1.添加完MySQL和jdbc約束後,在配置文件內spring.datasource.driver-class-name=com.mysql.jdbc.Driver 報錯,顯示找不到驅動包,原因是:

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>provided</scope>
        </dependency>

添加上scope約束,重新導入就好了。然後再次啟動項目,仍然報異常:

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.

意思是驅動包內的驅動類換了,改為:spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 後就好了。

創建spring boot 項目所遇到的問題