springboot配置MySQL8.0
时间: 2023-10-14 13:04:21 浏览: 571
spring项目jar包&mysql8;.0.11安装教程
在Spring Boot中配置MySQL 8.0的方式有多种。根据引用的内容,可以通过修改`pom.xml`文件和`application.properties`文件来配置MySQL 8.0。
首先,在`pom.xml`文件中添加以下依赖项:
```
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
```
这样就集成了MySQL数据库和Spring Boot JDBC。
接下来,打开`application.properties`文件,根据需要进行以下修改:
```
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/harvest?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true
spring.datasource.username=root
spring.datasource.password=root
```
这样,你就成功地配置了Spring Boot与MySQL 8.0的连接。请注意,`spring.datasource.url`中的参数可以根据你的需求进行修改,比如设置字符编码、关闭SSL等等。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [SpringBoot连接MySQL8.0的配置问题](https://blog.csdn.net/Moddlec/article/details/87382824)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [Springboot 连接 Mysql](https://blog.csdn.net/qq_41749451/article/details/126141915)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文