您应该将依赖项用于spring-boot-starter-data-jpa
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId></dependency>
要使用持久性xml,您应该按照文档中的定义定义一个bean。
Spring不需要使用XML来配置JPA提供程序,并且Spring
Boot假定您想利用该功能。如果您更喜欢使用persistence.xml,则需要定义自己的@Bean,其类型为LocalEntityManagerFactoryBean(标识为’entityManagerFactory’,并在其中设置持久性单元名称)。
http://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-
access.html#howto-use-traditional-persistence-
xml
或者,您可以完全跳过persistence.xml,并在application.properties文件中定义连接属性。
引用文档
DataSource配置由spring.datasource。*中的外部配置属性控制。例如,您可以在application.properties中声明以下部分:
spring.datasource.url=jdbc:mysql://localhost/testspring.datasource.username=dbuserspring.datasource.password=dbpassspring.datasource.driver-class-name=com.mysql.jdbc.Driver
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-
sql.html#boot-features-connect-to-production-
database
(更改驱动程序和其他数据以匹配您的环境)
祝好运!



