[SpringBoot] build.gradle 설정하기

C____JIN·2022년 10월 11일
0

SpringBoot

목록 보기
1/6
post-thumbnail
buildscript {
    ext {
        springBootVersion = '2.1.7.RELEASE'
    }
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}
  • ext : build.gradle에서 사용하는 전역변수를 설정
    • springBootVersion 전역변수를 생성하고 그 값을 '2.1.7.RELEASE'로 하겠다는 의미

즉, 스프링 부트 그레이들 플러그인의 2.1.7.RELEASE를 의존성으로 받겠다는 의미이다.


apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
  • io.spring.dependency-management : 스프링 부트의 의존성들을 관리해 주는 플러그인
  • 위의 4개의 플러그인 은 자바와 스프링 부트를 사용하기 위한 필수 플러그인

repositories {
    mavenCentral()
    jcenter()
}
  • repositories : 각종 의존성들을 어떤 저장소에서 받을지 결정
    • mavenCentral을 주로 사용
    • 최근 jcenter의 사용 빈도가 늘어남
      • 라이브러리 업로드를 간단하게 만듬

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
  • dependencies : 프로젝트 개발에 필요한 의존성들을 선언하는 곳

의존성 코드는 특정 버전을 명시하면 안된다.
버전을 명시하지 않아야 맨위에서 작성한 springBootVersion의 버전을 따라감

기타

Gradle Could not find method compile() 오류 발생 시

참고

이동욱, 스프링 부트와 AWS로 혼자 구현하는 웹 서비스

profile
개발 블로그🌐 개발일지💻

0개의 댓글