영한님의 강의를 보며 진행을하면서 초기 설정을 하다가 Gradle로 해보고 싶어서 찾아보게 되었다.
공식 레퍼런스 문서에서 /META-INF/persistence.xml
이런식으로 경로를 설정해주면 알아서 설정 파일을 참고한다고 한다.
더 궁금하다면 공식 레퍼런스 이쪽을 살펴보자.
아래의 xml 파일과 같은 형태를 갖추고 src/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="<!-- 여기에 EntityManagerFactory name 지정-->">
<class><!-- 엔티티 선언한 path를 지정해줘야함.--></class>
<properties>
<!-- 여기 안에 설정 정보들 넣어주면 됨.-->
</properties>
</persistence-unit>
</persistence>
gradle 설정은 다음과 같이 하였다.
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.h2database:h2:'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}