강사님 오류가 발생하였습니다.
name이 hello가 아니여서 그런가 해서 찾아봤더니 hello로 설정되어 있고,
persistance.xml도 META-INF 폴더 밑에 있는 것을 확인하였습니다.
파란색 줄이 그어진 JpaMain.java :10 은 해당 문구이며, createEntityManagerFactory부분에 생긴 문제 인 듯 합니다
EntityManagerFactory emf= Persistence.createEntityManagerFactory("hello"); //PersistenceUnitName
[persistacne.xml]
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
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_2.xsd">
<persistence-unit name="hello">
<class>jpabook.jpashop.domain.Member</class>
<class>jpabook.jpashop.domain.Item</class>
<class>jpabook.jpashop.domain.Order</class>
<class>jpabook.jpashop.domain.OrderItem</class>
<class>jpabook.jpashop.domain.OrderStatus</class>
<properties>
<!-- 필수 속성 -->
<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/~/jpashop"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<!-- 옵션 -->
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true"/>
<property name="hibernate.jdbc.batch_size" value="10"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
</persistence>
[JpaMain.java]
package jpabook.jpashop.JpaMain;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
public class JpaMain {
public static void main(String[] args){
EntityManagerFactory emf= Persistence.createEntityManagerFactory("hello"); //PersistenceUnitName
EntityManager em=emf.createEntityManager();
EntityTransaction tx=em.getTransaction();
tx.begin();
try{
tx.commit();
}catch(Exception e){
tx.rollback();
}finally {
em.close();
}
emf.close();
}
}
감사합니다 : )