JPA를 실행하려면 /META-INF/persistence.xml
설정파일을 작성해야 된다.
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="<http://xmlns.jcp.org/xml/ns/persistence>"
version="2.2"> <!-- JPA 버전을 지정한다. JPA 2.2 사용 -->
<persistence-unit name="testUnit"> <!-- persistence-unit 이름을 지정한다. -->
<properties>
<!-- DB Driver 설정 (필수) -->
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/~/test"/>
</properties>
</persistence-unit>
</persistence>
Jakarta 3.1 (최신버전) 사용방법
What’s New in Jakarta Persistence 3.1 By Examples
build.gradle
//hibernate-core
implementation 'org.hibernate.orm:hibernate-core:6.2.1.Final'
//jpa 3.1.0
implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'