Skip to content

Commit

Permalink
prod: jpa 및 기본 엔티티 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
gengminy committed Nov 29, 2023
1 parent ed02ac4 commit 4ef0c83
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 5 deletions.
29 changes: 25 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,34 @@ repositories {
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
// Lombok
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'

// DB
runtimeOnly 'com.mysql:mysql-connector-j'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

// Flyway
implementation 'org.flywaydb:flyway-mysql'
implementation 'org.flywaydb:flyway-core'

// MVC
implementation 'org.springframework.boot:spring-boot-starter-web'

// Validation
implementation('org.springframework.boot:spring-boot-starter-validation')

// jwt
implementation(group: 'io.jsonwebtoken', name: 'jjwt', version: '0.11.5')
implementation('io.jsonwebtoken:jjwt:0.9.1')

// Swagger
implementation ('org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.4')

// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.h2database:h2'
}

tasks.named('test') {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/testcar/car/CarApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication
@EnableJpaRepositories
public class CarApplication {

public static void main(String[] args) {
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/testcar/car/common/entity/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.testcar.car.common.entity;

import jakarta.persistence.Column;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.MappedSuperclass;
import java.time.LocalDateTime;
import lombok.Getter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

@Getter
@MappedSuperclass
public class BaseEntity {
@CreationTimestamp
@Column(nullable = false, updatable = false)
private LocalDateTime createdAt;

@UpdateTimestamp
@Column(nullable = false)
private LocalDateTime updatedAt;

@Column(nullable = false)
protected Boolean deleted = false;

public void delete() {
this.deleted = true;
}
}
1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

31 changes: 31 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
server:
port: 8080

spring:
sql:
init:
platform: mysql
datasource:
url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:test}?autoReconnect=true&setTimezone=Asia/Seoul
username: ${DB_USERNAME:test}
password: ${DB_PASSWORD:example}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
maximum-pool-size: ${MAX_CONNECTION_POOL_SIZE:30}
jpa:
database-platform: org.hibernate.dialect.MySQLDialect
hibernate:
ddl-auto: none
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
generate-ddl: false
show-sql: false
properties:
hibernate:
format_sql: false
flyway:
enabled: true
baseline-on-migrate: true
url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:test}?autoReconnect=true&setTimezone=Asia/Seoul
user: ${DB_USERNAME:test}
password: ${DB_PASSWORD:example}

0 comments on commit 4ef0c83

Please sign in to comment.