Web/📗 Spring

그레이들 프로젝트를 스프링 부트 프로젝트로 변경하기 [Spring / 스프링 부트와 AWS로 혼자 구현하는 웹 서비스]

키깡 2022. 7. 7.
728x90

build.gradle 변경 최종 코드

buildscript {    // buildscript : 그래들(Gradle)에서 buildscript는 보통 별도의 외부 라이브러리를 가져와야 할 때 사용
    ext{    // ext: build.gradle에서 사용하는 전역변수를 설정하겠다.
        springBootVersion = '2.1.7.RELEASE'
    }
    repositories {  //  repositories는 각종 의존성 (라이브러리) 들을 어떤 원격 저장소에서 받을 지 정함. 책에서는 jcenter도 사용하나, 현 시점 (22.07.07) 에 중지 되어, mavenCentral만 사용 가능
        mavenCentral()
        jcenter()
    }
    dependencies {
        //  spring-boot-gradle-plugin라는 스프링 부트 그레이들 플러그인의 springBootVersion(2.1.7.RELEASE)를 의존성으로 받겠다.
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management' //  스프링 부트의 의존성들을 관리해주는 플러그인

group 'com.izero'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    implementation('org.springframework.boot:spring-boot-starter-web')
    testImplementation('org.springframework.boot:spring-boot-starter-test') // implementation('org.springframework.boot:spring-boot-starter-test')도 가능
}
  • gradle에 라이브러리 추가하는 implementation 종류

    1. implementation : 항상 적용.

    2. debugImplementation : 디버그 빌드 시에만 적용.

    3. releaseImplementation : 릴리즈 빌드 시에만 적용.

    4. testImplementation : 테스트 코드를 수행할 때만 적용.

댓글