작성
·
395
·
수정됨
0
java 소스에서는 EntityManager em 사용시 오류가 안나는데,
test소스에서 EntityManager em @Autowired 시 빨간줄로 오류가 생깁니다 ㅠㅠ..
build.gradel, tsetd의 application.yml 같이 올립니다 무슨이유 인지 모르겠습니다 ㅜㅜ..
buildscript {
ext {
queryDslVersion = "5.0.0"
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.1'
id 'io.spring.dependency-management' version '1.1.0'
//querydsl 추가
//id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}
group = 'saft'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation' // NotEmpty
compileOnly 'org.projectlombok:lombok'
//runtimeOnly 'com.h2database:h2:1.4.199'
implementation 'com.h2database:h2'
//querydsl 추가
//implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
//annotationProcessor "com.querydsl:querydsl-apt:${queryDslVersion}"
implementation 'com.querydsl:querydsl-jpa:5.0.0'
// implementation 'com.querydsl:querydsl-apt:5.0.0'
// 추가 ↓
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jpa"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
//파라미터 확인 라이브러리
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.8'
// MapStruct
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor "org.mapstruct:mapstruct-processor:1.4.2.Final"
annotationProcessor(
'org.projectlombok:lombok',
'org.projectlombok:lombok-mapstruct-binding:0.1.0'
)
//test추가
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
/*
//querydsl 추가 시작
def querydslDir = "$buildDir/generated/querydsl"
querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
compileQuerydsl{
options.annotationProcessorPath = configurations.querydsl
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
querydsl.extendsFrom compileClasspath
}
//querydsl 추가 끝
*/
def generatedDir = "src/main/generated"
clean {
delete file(generatedDir)
}
spring:
profiles:
active: test
datasource:
url: jdbc:h2:tcp://localhost/~/saft
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create
properties:
hibernate:
# show_sql: true
format_sql: true
use_sql_comments: true
logging.level:
org.hibernate.SQL: debug
# org.hibernate.type: trace