From 3328bf02143153daeb34275a7e92200caec8dd43 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Wed, 25 May 2022 12:27:50 +0900 Subject: [PATCH 1/2] =?UTF-8?q?config=20:=20gradle=20com.ewerk.gradle.plug?= =?UTF-8?q?ins.querydsl=20plugin=20=EC=A0=9C=EA=B1=B0=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20Gradle=20Annotation=20processor=EB=A5=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 79 ++++++++++------------------------------------------ 1 file changed, 15 insertions(+), 64 deletions(-) diff --git a/build.gradle b/build.gradle index 0238089..0ab0e17 100644 --- a/build.gradle +++ b/build.gradle @@ -13,9 +13,6 @@ buildscript { dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion") - - // JPA querydsl - //classpath("gradle.plugin.com.ewerk.gradle.plugins:querydsl-plugin:1.0.10") } } @@ -25,14 +22,6 @@ plugins { id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'war' - //id 'net.ltgt.apt' version '0.21' - // querydsl - id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10' - //id 'org.openapi.generator' version '5.1.1' - - // docker : jib - // bootWar --> jibDockerBuild - //id 'com.google.cloud.tools.jib' version '3.1.2' // } // buildscript @@ -125,16 +114,18 @@ dependencies { implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.8.0' // implementation 'p6spy:p6spy:3.9.1' - // JPA querydsl - implementation "com.querydsl:querydsl-jpa:${queryDslVersion}" - implementation "com.querydsl:querydsl-core:${queryDslVersion}" - implementation "com.querydsl:querydsl-apt:${queryDslVersion}" - annotationProcessor( - "javax.persistence:javax.persistence-api", - "javax.annotation:javax.annotation-api", - "com.querydsl:querydsl-apt:${queryDslVersion}:jpa") - - // JPA mapstruct : lombok 과 함께 사용시 반드시 순서 지겨야 함다 - ㅡmapstruct이 먼저 선언된 경우 + // JPA querydsl ---------------------------------------------- + implementation "com.querydsl:querydsl-jpa" + // querydsl JPAAnnotationProcessor 사용 지정 + annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jpa" + // java.lang.NoClassDefFoundError(javax.annotation.Entity) 발생 대응 + annotationProcessor "jakarta.persistence:jakarta.persistence-api" + // java.lang.NoClassDefFoundError (javax.annotation.Generated) 발생 대응 + annotationProcessor "jakarta.annotation:jakarta.annotation-api" + // ------------------------------------------------------------ + + // JPA mapstruct ----------------------------------------------------------- + // lombok 과 함께 사용시 반드시 순서 지겨야 함다 - ㅡmapstruct이 먼저 선언된 경우 // target class 에 @Builder 가 있어도 무시하고 생성자 + setter 를 사용하므로 정상적으로 Mapper 클래스를 Generation 하기 위해서 // @NoArgsConstructor, @Setter 가 필요 // but, 최근 Setter 사용을 지양하는 추세라 mapstruct를 먼저 오도록 해서 @Builder 방식으로 Generation @@ -267,52 +258,12 @@ tasks.withType(JavaCompile) { //-----------------------------------------------------------------------------------// // querydsl //-----------------------------------------------------------------------------------// -def querydslDir = "$buildDir/generated" - -// querydsl 적용 -sourceSets { - main { - java { - srcDirs = ["$projectDir/src/main/java", querydslDir] - } - } -} -querydsl { - jpa = true - querydslSourcesDir = querydslDir +/** clean 태스크 실행시 QClass 삭제 */ +clean { + delete file('src/main/generated') // 인텔리제이 Annotation processor 생성물 생성위치 } -configurations { - compileOnly { - extendsFrom annotationProcessor - } - querydsl.extendsFrom compileClasspath -} - -compileQuerydsl { - options.annotationProcessorPath = configurations.querydsl -} - -// build시 querydsl 삭제후 재 컴파일 -compileQuerydsl.doFirst { - if(file(querydslDir).exists()) - delete(file(querydslDir)) -} - -// build시 querydsl 적용 -compileJava { - options.compilerArgs << '-s' - options.compilerArgs << "$buildDir/generated/" - - doFirst { - if(file(querydslDir).exists()) - delete(file(querydslDir)) - file(querydslDir).mkdirs(); - } -} -//-----------------------------------------------------------------------------------// - test { exclude '**/*' //useJUnitPlatform() From 96c957b851126668c6475aa39437cabb732cdc4a Mon Sep 17 00:00:00 2001 From: minuk926 Date: Wed, 25 May 2022 12:41:53 +0900 Subject: [PATCH 2/2] =?UTF-8?q?config=20:=20gradle=20com.ewerk.gradle.plug?= =?UTF-8?q?ins.querydsl=20plugin=20=EC=A0=9C=EA=B1=B0=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20Gradle=20Annotation=20processor=EB=A5=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 9 +++++++++ ...tFrameworkApplicationCommandLineRunner.java | 18 ------------------ .../com/xit/core/JasyptApplicationTests.java | 2 +- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index 0ab0e17..f732450 100644 --- a/build.gradle +++ b/build.gradle @@ -260,6 +260,15 @@ tasks.withType(JavaCompile) { //-----------------------------------------------------------------------------------// /** clean 태스크 실행시 QClass 삭제 */ +/** + * Intellij IDEA - Build, Execution, Deployment - Build tools → Gradle 에서 ‘Build and run’ 설정값에 따라 ‘Annotation processor’ 생성물 위치가 달라짐 + * Gradle: 각 모듈별 build/generated/sources/annotationProcessor/java/main + * ‘Q생성물’에 대한 별도의 정리작업을 하지 않아도 clean 태스크로 정리 가능 + * IntellijI IDEA: 각 모듈별 src/main/generated + * Compiler Annotation procesoors 설정영향받음 + * 기존 Q클래스는 갱신되지만, 엔티티 위치가 변경되거나 삭제된 경우 Q클래스는 그대로 유지 + * Build, Execution, Deployment - Compiler -> Enable annotaion processing 활성화 필요 + */ clean { delete file('src/main/generated') // 인텔리제이 Annotation processor 생성물 생성위치 } diff --git a/src/main/java/com/xit/core/init/XitFrameworkApplicationCommandLineRunner.java b/src/main/java/com/xit/core/init/XitFrameworkApplicationCommandLineRunner.java index 8192586..646a827 100644 --- a/src/main/java/com/xit/core/init/XitFrameworkApplicationCommandLineRunner.java +++ b/src/main/java/com/xit/core/init/XitFrameworkApplicationCommandLineRunner.java @@ -27,23 +27,5 @@ public class XitFrameworkApplicationCommandLineRunner implements CommandLineRunn //System.out.println(new SCryptPasswordEncoder().encode("gnadmin")); //System.out.println(new DelegatingPasswordEncoder().encode("gnadmin", "")); //System.out.println(new Pbkdf2PasswordEncoder().encode("gnadmin")); - - String url = "jdbc:oracle:thin:@211.119.124.118:1521:bustms"; - String username = "traffic"; - String password = "xhdgkq0"; - - System.out.println(jasyptEncoding(url)); - System.out.println(jasyptEncoding(username)); - System.out.println(jasyptEncoding(password)); - } - - - private String jasyptEncoding(String value) { - - String key = "xit_jasypt_key"; - StandardPBEStringEncryptor pbeEnc = new StandardPBEStringEncryptor(); - pbeEnc.setAlgorithm("PBEWithMD5AndDES"); - pbeEnc.setPassword(key); - return pbeEnc.encrypt(value); } } diff --git a/src/test/java/com/xit/core/JasyptApplicationTests.java b/src/test/java/com/xit/core/JasyptApplicationTests.java index bd61890..6a81ba7 100644 --- a/src/test/java/com/xit/core/JasyptApplicationTests.java +++ b/src/test/java/com/xit/core/JasyptApplicationTests.java @@ -6,7 +6,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; @SpringBootTest -@ActiveProfiles(value="dev") +//@ActiveProfiles(value="dev") class JasyptApplicationTests { @Test