概述
JPA(Java Persistence API), JPA是一个ORM的标准规范,而不是一个具体的ORM框架
不知道是不是版本问题,直接使用org.eclipse.persistence的包稍加配置可以直接使用无连接池的JPA
使用
- 配置
- 导包
<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.jpa -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.3</version>
</dependency>
- 配置持久化单元对应的配置文件,classpath下的META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="hotel">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.lusr.entity.Member</class>