Skip to content

Commit

Permalink
feature: setting querydsl & connecting mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongh00 committed Mar 8, 2023
1 parent f3031a6 commit a29c7a1
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bin/
*.iws
*.iml
*.ipr
*.yml
out/
!**/src/main/**/out/
!**/src/test/**/out/
Expand Down
42 changes: 41 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -21,17 +28,50 @@ 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'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
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
}
15 changes: 15 additions & 0 deletions src/main/java/com/dashboardbe/dashboardbe/domain/User.java
Original file line number Diff line number Diff line change
@@ -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;
}
1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

20 changes: 20 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a29c7a1

Please sign in to comment.