- Spring Boot ORM 教程
- Spring Boot ORM - 主页
- Spring Boot ORM - 概述
- 环境设置
- Spring Boot ORM 和 Spring Data JPA
- Spring Boot ORM - 创建项目
- 应用程序属性
- Spring Boot ORM - 更新项目
- Spring Boot ORM - 测试 Hibernate
- Spring Boot ORM 和 EclipseLink
- Maven EclipseLink
- 更新项目 EclipseLink
- Spring Boot ORM - 测试 EclipseLink
- Spring Boot ORM 有用资源
- Spring Boot ORM - 快速指南
- Spring Boot ORM - 有用的资源
- Spring Boot ORM - 讨论
Spring Boot ORM - Maven EclipseLink
Spring Boot 默认使用 Hibernate 作为 ORM 实现。为了使用EclipseLink,我们首先需要从pom.xml中的spring-data-jpa依赖中排除hibernate依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <exclusions> <exclusion> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> </exclusion> <exclusion> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </exclusion> </exclusions> </dependency>
现在在pom.xml中包含 eclipse-link 依赖项。
<dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa</artifactId> <version>2.7.8</version> </dependency>
以下是完整的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 https://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>2.5.5</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.tutorialspoint</groupId> <artifactId>springbootorm</artifactId> <version>0.0.1-SNAPSHOT</version> <name>Spring Boot ORM</name> <description>Demo project for Spring Boot ORM</description> <properties> <java.version>11</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <exclusions> <exclusion> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> </exclusion> <exclusion> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa</artifactId> <version>2.7.8</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
保存文件,eclipse将自动更新依赖项。