[JPA] JPA 프로젝트 의존성과 application.properties 설정

Dawon Seo·2022년 8월 23일
0

JPA

목록 보기
2/5

첫 JPA 프로젝트를 시작하게 됐다!
늘 환경 설정에서 버벅거리는 나... 다음 프로젝트 시작 때에도 참고할 수 있도록 이 기회에 JPA 환경 설정을 기록해 놓기로 했다 😂

Maven, PostgerSQL을 기준으로 설정했다

  1. (New > Spring Starter Project) Spring Boot 프로젝트 생성
  1. pom.xml에 의존성 추가
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Spring Data JPA-->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- PostgreSQL 데이터베이스 -->
<dependency>
	<groupId>org.postgresql</groupId>
	<artifactId>postgresql</artifactId>
</dependency>
<!-- log4j -->
<dependency>
	<groupId>org.bgee.log4jdbc-log4j2</groupId>
	<artifactId>log4jdbc-log4j2-jdbc4</artifactId>
	<version>1.16</version>
</dependency>
<!-- lombok -->
<dependency>
	<groupId>org.projectlombok</groupId>
  	<artifactId>lombok</artifactId>
	<version>1.18.24</version>
	<scope>provided</scope>
</dependency>
  1. aplication.properties에 DB 정보와 JPA 설정
server.port = {사용할 포트 번호}

# PostgreSQL
spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.url=jdbc:log4jdbc:postgresql://${POSTGRES}:{포트}/{DB이름}
spring.datasource.username={username}
spring.datasource.password={password}

# JPA 설정
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL10Dialect

POSTGRES = localhost

0개의 댓글