栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何将Spring Boot与MySQL数据库和JPA一起使用?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何将Spring Boot与MySQL数据库和JPA一起使用?

我像你一样创建了一个项目。结构看起来像这样

这些类只是复制自你的类。

我将application.properties更改为:

spring.datasource.url=jdbc:mysql://localhost/testprojectspring.datasource.username=rootspring.datasource.password=rootspring.datasource.driverClassName=com.mysql.jdbc.Driverspring.jpa.hibernate.ddl-auto=update

但我认为你的问题出在你的pom.xml中:

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-parent</artifactId>    <version>1.4.1.RELEASE</version></parent><artifactId>spring-boot-sample-jpa</artifactId><name>Spring Boot JPA Sample</name><description>Spring Boot JPA Sample</description><dependencies>    <dependency>        <groupId>mysql</groupId>        <artifactId>mysql-connector-java</artifactId>    </dependency>    <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></dependencies><build>    <plugins>        <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId>        </plugin>    </plugins></build>

检查这些文件是否有差异。希望这可以帮助



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/415101.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号