spring boot 通过jpa连接mysql失败
答案:2 悬赏:40 手机版
解决时间 2021-03-12 22:52
- 提问者网友:风月客
- 2021-03-12 03:08
spring boot 通过jpa连接mysql失败
最佳答案
- 五星知识达人网友:独行浪子会拥风
- 2021-03-12 04:32
步骤一:在pom.xml文件中添加MYSQl和JPA的相关Jar包依赖,具体添加位置在dependencies中,具体添加的内容如下所示。
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-data-jpa
mysql
mysql-connector-java
org.apache.poi
poi
3.11
步骤二:在application.properties配置文件中加入数据库的相关配置,配置信息如下所示。
spring.datasource.url = jdbc:mysql://localhost:3306/webtest
spring.datasource.username = root
spring.datasource.password = 220316
spring.datasource.driverClassName = com.mysql.jdbc.Driver
# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# stripped before adding them to the entity manager)
spring.jpa.properties.hibernate.dialect = org.hibernate.dial
spring-boot-starter-web
spring-boot-starter-data-jpa
mysql-connector-java
poi
步骤二:在application.properties配置文件中加入数据库的相关配置,配置信息如下所示。
spring.datasource.url = jdbc:mysql://localhost:3306/webtest
spring.datasource.username = root
spring.datasource.password = 220316
spring.datasource.driverClassName = com.mysql.jdbc.Driver
# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# stripped before adding them to the entity manager)
spring.jpa.properties.hibernate.dialect = org.hibernate.dial
全部回答
- 1楼网友:孤独入客枕
- 2021-03-12 05:33
Mysql服务没打开
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯