게시글
질문&답변
2023.12.15
Spring Data Jpa Optional
public Item findOne(Long itemId){ Item item = itemRepository.findById(itemId).orElseThrow(() -> new IllegalArgumentException("no such item")); return item; }이런식으로 변경해보았는데 맞을까요??
- 0
- 2
- 392
질문&답변
2023.10.15
querydsl
buildscript { dependencies { classpath("gradle.plugin.com.ewerk.gradle.plugins:querydsl- plugin:1.0.10") } } plugins { id 'java' id 'org.springframework.boot' version '3.1.4' id 'io.spring.dependency-management' version '1.1.3' } group = 'jpabook' 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-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:3.1.4' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-hibernate5-jakarta' //Querydsl 추가 implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api" testImplementation 'org.projectlombok:lombok:1.18.22' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' //querydsl 추가 implementation 'com.querydsl:querydsl-jpa' //querydsl 추가 implementation 'com.querydsl:querydsl-apt' } //querydsl 추가 //def querydslDir = 'src/main/generated' def querydslDir = "$buildDir/generated/querydsl" querydsl { library = "com.querydsl:querydsl-apt" jpa = true querydslSourcesDir = querydslDir } sourceSets { main { java { srcDirs = ['src/main/java', querydslDir] } } } compileQuerydsl{ options.annotationProcessorPath = configurations.querydsl } configurations { querydsl.extendsFrom compileClasspath } tasks.named('test') { useJUnitPlatform() }강의자료에 있는 내용을 더 추가했지만 안됩니다.
- 0
- 3
- 416