spring boot 通过jpa连接mysql失败

spring boot 通过jpa连接mysql失败,第1张

步骤一:在pom.xml文件中添加MYSQl和JPA的相关Jar包依赖,具体添加位置在dependencies中,具体添加的内容如下所示

<!--数据库相关配置-->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-data-jpa</artifactId>

</dependency>

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

</dependency>

<dependency>

<groupId>org.apache.poi</groupId>

<artifactId>poi</artifactId>

<version>3.11</version>

</dependency>

步骤二:在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

springboot+JPA连接不上mysql数据库ErrorstartingApplicationContext.Todisplaytheauto-configurationreportre-runyourapplicationwith'debug'enabled.2017-06-1515:04:37.122ERROR10072---[restartedMain]o.s.boot.SpringApplication:Applicationstartupfailed


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5919302.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-08
下一篇 2023-03-08

发表评论

登录后才能评论

评论列表(0条)

保存