본문 바로가기

프로그래밍언어/JAVA SPRING

SpringBoot build.gradle 설정 에러 Could not find method compile()

'스프링 부트와 AWS로 혼자 구현하는 웹서비스 ' 를 따라하는 도중 에러가 발생

 


Build file 'D:\Intelij\intellij-webservice\build.gradle' line: 35

A problem occurred evaluating root project 'intellij-webservice'.
> Could not find method compile() for arguments [org.springframework.boot:spring-boot-starter-web] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

 

 

-- 책에 나와있는 소스

buildscript {
        ext{
            springBootVersion = '2.1.7.RELEASE'
        }
        repositories {
            mavenCentral()
            jcenter()
        }
        dependencies {
                classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion }")
        }

}

group 'com.jojoldu.book'
version '1.0.4-SNAPSHOT-'+new Date().format("yyyyMMddHHmmss")


apply plugin : 'java'
apply plugin : 'eclipse'
apply plugin : 'org.springframework.boot'
apply plugin : 'io.spring.dependency-management'



group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
     jcenter()
}

dependencies {

    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')

}


 

compile() 소스가 없다고 에러가나와서 charGPT에 물어보니

 

"compile()" 메소드는 Gradle 4.10 버전 이전에 사용되었고,

이후로는 "implementation()"이나 "api()"로 대체되었습니다.

따라서 이러한 오류가 발생하는 것은 Gradle 버전이 최신화되어 "compile()" 메소드가 더 이상 사용되지 않기 때문입니다.

 

 

 

수정된코드 


buildscript {
        ext{
            springBootVersion = '2.1.7.RELEASE'
        }
        repositories {
            mavenCentral()
            jcenter()
        }
        dependencies {
                classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion }")
        }

}

group 'com.jojoldu.book'
version '1.0.4-SNAPSHOT-'+new Date().format("yyyyMMddHHmmss")


apply plugin : 'java'
apply plugin : 'eclipse'
apply plugin : 'org.springframework.boot'
apply plugin : 'io.spring.dependency-management'



group 'org.jojoldu.book'
version '1.0.4-SNAPSHOT-'+new Date().format("yyyyMMddHHmmss")

repositories {
    mavenCentral()
    jcenter()
}

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'

}

BUILD SUCCESSFUL in 1s