Gradle Could not find method compile() 해결 방법

찌글렛·2022년 5월 27일
0

java

목록 보기
9/15

apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"

repositories {
mavenCentral()
}

dependencies {
compile 'org.springframework:spring-context:5.0.2.RELEASE'
}

task wrapper(type: Wrapper) {
gradleVersion = '7.3.3'
}
위의 코드는 오류를 발생시켰다.
오류는 아래와 같다.

Could not find method compile() for arguments [org.springframework:spring-context:5.0.2.RELEASE] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

compile, runtime, testCompile, testRuntime 은 Gradle 4.10 (2018.8.27) 이래로
deprecate 되었다.
그리고 Gradle 7.0 (2021.4.9) 부터 삭제되었다.

필자는 Gradle 7.3.3 을 이용하고 있어서 삭제된 명령을 사용했으므로 오류가 발생했었다.
삭제된 네 명령은 각각 implementation, runtimeOnly, testImplementation, testRuntimeOnly 으로 대체되었다.
따라서 compile 을 implementation 으로 수정하여 오류를 해결했다.

0개의 댓글