6.환경설정 파일
1. Persistence.xml
EntityManagerFactory가 참조하는 설정 파일로, XML 형식으로 작성되었으며, 프로그램 동작 시 아래의 설정 정보를 토대로 데이터 접근 작업을 위한 설정이 구성됨
persistence.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="{PROJECT_NAME}">
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/{DATABASE_NAME}"/>
<property name="javax.persistence.jdbc.user" value="{USER_NAME}"/>
<property name="javax.persistence.jdbc.password" value="{PASSWORD}"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect" />
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>2. 파일 작성 경로 규칙
위 기술문서 링크에는 JPA 설정 파일(persistence.xml) 작성 방법에 대한 명세가 작성되어 있음
An object/relational mapping XML file named
orm.xmlmay be specified in theMETA-INFdirectory in the root of the persistence unit or in theMETA-INFdirectory of any jar file referenced by thepersistence.xml.Alternatively, or in addition, one or more mapping files may be referenced by the mapping-file elements of the persistence-unit element. These mapping files may be present anywhere on the classpath. — Section 8.2.1.6.2 of the Jakarta Persistence
Last updated on