diff --git a/.gitignore b/.gitignore index c2065bc..a04fa92 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ bin/ *.iws *.iml *.ipr +*.yml out/ !**/src/main/**/out/ !**/src/test/**/out/ diff --git a/build.gradle b/build.gradle index b0e742f..d6add04 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,14 @@ +buildscript { + ext { + queryDslVersion = "5.0.0" + } +} + plugins { id 'java' id 'org.springframework.boot' version '2.7.9' id 'io.spring.dependency-management' version '1.0.15.RELEASE' + id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" } group = 'com.DashboardBE' @@ -21,8 +28,12 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-data-redis' - implementation 'org.springframework.boot:spring-boot-starter-security' + //implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-web' + // querydsl 디펜던시 추가 + implementation "com.querydsl:querydsl-jpa:${queryDslVersion}" + implementation "com.querydsl:querydsl-apt:${queryDslVersion}" + compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' runtimeOnly 'com.mysql:mysql-connector-j' @@ -30,8 +41,37 @@ dependencies { annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' + } tasks.named('test') { useJUnitPlatform() } + +// querydsl 사용할 경로 지정합니다. 현재 지정한 부분은 .gitignore에 포함되므로 git에 올라가지 않습니다. +def querydslDir = "$buildDir/generated/'querydsl'" + +// JPA 사용여부 및 사용 경로 설정 +querydsl { + jpa = true + querydslSourcesDir = querydslDir +} + +// build시 사용할 sourceSet 추가 설정 +sourceSets { + main.java.srcDir querydslDir +} + + +// querydsl 컴파일 시 사용할 옵션 설정 +compileQuerydsl { + options.annotationProcessorPath = configurations.querydsl +} + +// querydsl이 compileClassPath를 상속하도록 설정 +configurations { + compileOnly { + extendsFrom annotationProcessor + } + querydsl.extendsFrom compileClasspath +} diff --git a/src/main/java/com/dashboardbe/dashboardbe/domain/User.java b/src/main/java/com/dashboardbe/dashboardbe/domain/User.java new file mode 100644 index 0000000..c430861 --- /dev/null +++ b/src/main/java/com/dashboardbe/dashboardbe/domain/User.java @@ -0,0 +1,15 @@ +package com.dashboardbe.dashboardbe.domain; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity(name = "user") +public class User { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String username; + private String password; +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..e741e2a --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,20 @@ +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/ST_DASHBOARD?serverTimezone=Asia/Seoul + username: root + password: root + + jpa: + hibernate: + ddl-auto: create-drop + + properties: + hibernate: + format_sql: true + show-sql: true + +logging: + level: + sql: info +