Spring
스프링부트 오라클 연동
JJJAEOoni
2022. 6. 14. 22:53
반응형
1. build.gradle 의존성 추가
runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
2. 설정파일 등록
spring:
datasource:
url: jdbc:oracle:thin:@localhost:1521/xe
driver-class-name: oracle.jdbc.driver.OracleDriver
username: SCOTT
password: TIGER
3. 엔티티 시퀀스 등록
package site.metacoding.baseballmanage.domain.stadium;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@EntityListeners(AuditingEntityListener.class)
@Entity
public class Stadium {
@Id
// @GeneratedValue(strategy = GenerationType.IDENTITY) mariaDB auto_increment
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "xxx_SEQUENCE_GENERATOR")
@SequenceGenerator(name = "xxx_SEQUENCE_GENERATOR", sequenceName = "xxx_SEQUENCE", initialValue = 1, allocationSize = 1)
private Integer id;
}
반응형