(1)springboot开发教程-初始化项目

zhuc 2024-06-05 23 阅读

1初始化项目


使用阿里云脚手架https://start.aliyun.com/


配置项目基本信息,选择jar java版本8


选择springweb


选择jdbc及mysql驱动



点击获取代码进行下载,用idea加载项目


发现下载的代码无法运行;

Description:


Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.


Reason: Failed to determine a suitable driver class

修改pom.xml文件 ,mysql驱动指定版本号


<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.26</version>
</dependency>


application.properties文件中增加数据库配置


spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver
spring.datasource.url= jdbc:mysql://localhost:3306/springbootdb
spring.datasource.password= root
spring.datasource.username= root