-
Notifications
You must be signed in to change notification settings - Fork 2
Description
=> ERROR [springboot build 9/9] RUN ./gradlew build -x test --no-daemon 89.5s
------
> [springboot build 9/9] RUN ./gradlew build -x test --no-daemon:
0.390 Downloading https://services.gradle.org/distributions/gradle-8.8-bin.zip
2.302 .............10%.............20%.............30%.............40%.............50%.............60%..............70%.............80%.............90%.............100%
14.04
14.04 Welcome to Gradle 8.8!
14.04
14.04 Here are the highlights of this release:
14.04 - Running Gradle on Java 22
14.05 - Configurable Gradle daemon JVM
14.05 - Improved IDE performance for large projects
14.05
14.05 For more details see https://docs.gradle.org/8.8/release-notes.html
14.05
14.14 To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.8/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
15.44 Daemon will be stopped at the end of the build
80.44 > Task :processResources
80.44 > Task :check
88.84
88.84 > Task :compileKotlin
88.84 e: file:///app/src/main/java/com/TreeNut/ChatBot_Backend/service/ChatroomService.kt:8:32 Unresolved reference: reactive
88.84 e: file:///app/src/main/java/com/TreeNut/ChatBot_Backend/service/ChatroomService.kt:9:8 Unresolved reference: reactor
88.84 e: file:///app/src/main/java/com/TreeNut/ChatBot_Backend/service/ChatroomService.kt:14:28 Unresolved reference: WebClient
88.84 e: file:///app/src/main/java/com/TreeNut/ChatBot_Backend/service/ChatroomService.kt:32:20 Unresolved reference: it
88.94
88.94
88.94 FAILURE: Build failed with an exception.
88.94
88.94 * What went wrong:
88.94 Execution failed for task ':compileKotlin'.
88.94 > Task :compileKotlin FAILED
88.94 > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
88.94 > Compilation error. See log for more details
88.94
88.94 * Try:
88.94 > Run with --stacktrace option to get the stack trace.
88.94 > Run with --info or --debug option to get more log output.
88.94 > Run with --scan to get full insights.
88.94 > Get more help at https://help.gradle.org.
88.94
88.94 Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
88.94
88.94 You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
88.94
88.94 For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
88.94
88.94 BUILD FAILED in 1m 28s2 actionable tasks: 2 executed
88.94
------
failed to solve: process "/bin/sh -c ./gradlew build -x test --no-daemon" did not complete successfully: exit code: 1
Failed to execute docker-compose up. Exiting...📦src
┣ 📂main
┃ ┣ 📂java
┃ ┃ ┗ 📂com
┃ ┃ ┃ ┗ 📂TreeNut
┃ ┃ ┃ ┃ ┗ 📂ChatBot_Backend
┃ ┃ ┃ ┃ ┃ ┣ 📂controller
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂config
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜WebClientConfig.kt <-- 여기 파일 추가
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ChatroomController.kt
┃ ┃ ┃ ┃ ┃ ┣ 📂exceptions
┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TokenAuthException.kt
┃ ┃ ┃ ┃ ┃ ┣ 📂middleware
┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜TokenAuth.kt
┃ ┃ ┃ ┃ ┃ ┣ 📂model
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Chatroom.kt
┃ ┃ ┃ ┃ ┃ ┃ ┗ 📜User.kt
┃ ┃ ┃ ┃ ┃ ┣ 📂repository
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ChatroomRepository.kt
┃ ┃ ┃ ┃ ┃ ┣ 📂service
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜ChatroomService.kt
┃ ┃ ┃ ┃ ┃ ┗ 📜ChatBotBackendApplication.kt
┃ ┗ 📂resources
┃ ┃ ┗ 📜application.properties
┣ 📂test
┗ 📜build.gradle.kts <-- 여기 의존성 추가
Bug 해결 문서: WebClient 관련 의존성 오류 해결
문제 개요
Spring Boot 프로젝트에서 gradlew build -x test 명령어를 실행할 때, ChatroomService.kt에서 아래와 같은 오류가 발생하였습니다.
Unresolved reference: reactive
Unresolved reference: reactor
Unresolved reference: WebClient
오류의 주요 원인은 Spring WebFlux와 WebClient 관련 의존성이 누락된 상태에서 WebClient를 사용하려 했기 때문입니다.
문제 원인
ChatroomService.kt 파일 내에서 WebClient와 Reactive 관련 기능을 사용하려고 시도했으나, 이에 필요한 Spring WebFlux 의존성이 build.gradle.kts에 추가되지 않았습니다.
관련 오류 메시지
Unresolved reference: reactiveUnresolved reference: reactorUnresolved reference: WebClient
이는 프로젝트가 WebFlux 의존성을 인식하지 못하고, 컴파일 시 관련 패키지를 찾을 수 없어 발생한 오류입니다.
해결 방법
1. build.gradle.kts에 WebFlux 의존성 추가
WebFlux 및 WebClient 관련 클래스를 사용하기 위해서는 Spring WebFlux 의존성이 추가되어야 합니다. 이를 위해 build.gradle.kts 파일의 dependencies 블록에 아래의 의존성을 추가합니다.
dependencies {
// 기존 의존성
// WebFlux 관련 의존성 추가
implementation("org.springframework.boot:spring-boot-starter-webflux")
}2. WebClientConfig.kt 파일 추가
WebClient를 사용할 때는 일반적으로 WebClient 빌더를 Bean으로 등록하여 여러 클래스에서 주입받을 수 있게 설정하는 것이 좋습니다. 이를 위해 WebClientConfig.kt 파일을 추가하여, WebClient.Builder를 Bean으로 등록합니다.
WebClientConfig.kt
package com.TreeNut.ChatBot_Backend.config
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.reactive.function.client.WebClient
@Configuration
class WebClientConfig {
@Bean
fun webClientBuilder(): WebClient.Builder {
return WebClient.builder()
}
}3. 의존성 추가 후 gradlew build -x test 실행
위의 두 단계를 완료한 후 다시 gradlew build -x test 명령어를 실행하면 WebClient와 관련된 의존성 오류가 해결됩니다.
결론
WebClient와 같은 Reactive 기능을 사용하기 위해서는 반드시 spring-boot-starter-webflux 의존성을 추가해야 하며, WebClient.Builder를 Bean으로 등록하여 적절히 사용할 수 있게 설정해야 합니다. 이번 오류는 이러한 설정이 누락되어 발생한 문제였으며, build.gradle.kts와 WebClientConfig.kt 파일을 수정함으로써 해결되었습니다.
최종 빌드 성공 예시
의존성 추가 후 gradlew build -x test 명령어를 성공적으로 실행하면, 아래와 같은 메시지가 출력됩니다.
BUILD SUCCESSFUL in Xs
2 actionable tasks: 2 executed
이를 통해 WebFlux 관련 기능이 정상적으로 적용되었음을 확인할 수 있습니다.