用户登录
用户注册

分享至

hibernate jpa 连接数据库

  • 作者: 我有一个大秘密
  • 来源: 51数据库
  • 2021-01-18
springboot+JPA连接不上mysql数据库
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-06-15 15:04:37.122 ERROR 10072 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed



  步骤一:在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
软件
前端设计
程序设计
Java相关