提示:下面案例仅供参考!
一、MySQL数据库是什么?
MySQL是一个开源的关系型数据库管理系统,常用于Web应用程序的后端数据存储。它支持多种操作系统和编程语言,具有高性能、可靠性和可扩展性等特点。
二、使用步骤
1.创建IEDR项目时勾选SQL中的MySQL Driver;
图片如下(示例):
2.项目创建成功把application.properties的后缀改为yml
图片如下(示例):
3.application.yml里的代码如下
#MySQL数据库5.0低版本:
#配置mysql的连接
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/java ---数据库名
username: root
password: root
#配置thymeleaf
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML5
encoding: UTF-8
servlet:
content-type: text/html
cache: false
#<!--启动图标-->
banner.location: classpath:banner.txt
#MySQL数据库8.0高版本:
#配置mysql的连接
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/java ---数据库名
username: root
password: root
#配置thymeleaf
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML5
encoding: UTF-8
servlet:
content-type: text/html
cache: false
#<!--启动图标-->
banner.location: classpath:banner.txt
谢谢大家!!!新手上路多多关照!!!不对的地方请大佬指出谢谢!!!