728x90
main -> resources -> META_INF (폴더 생성) -> persistence.xml 생상
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">
<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/~/test"/>
<!-- 무슨 DB 상요하는지 -->
<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"/>
<!-- JPA 실행시 테이블을 어떻게 할건지 -->
<!--<property name="hibernate.hbm2ddl.auto" value="create" />-->
</properties>
</persistence-unit>
</persistence>
실행 시켰을때 이렇게 나오면 정상
# Persistence.createEntityManagerFactory("hello"); 여기서 "hello"는 persistence.xml 에서
<persistence-unit name="hello"> 의 name 값이다
728x90
'백엔드 > Spring(Boot)' 카테고리의 다른 글
JPA 필드와 컬럼 매핑 (0) | 2021.08.26 |
---|---|
JPA 엔티티 생성시 테이블 명 및 칼럼 명 변경 (0) | 2021.08.25 |
JPA 엔티티 설계시 주의점 (0) | 2021.08.22 |
JPA 테이블 컬럼명 생성 전략 (0) | 2021.08.22 |
JPA 쿼리 및 로그 확인 (0) | 2021.08.21 |