*모든 내용은 책에 있는 내용을 기반으로 작성하였습니다.
1장 ----
책에 있는 내용을 그대로 따름...
그레이들 프로젝트를 스프링 부트 프로젝트로 변경한다.
Gradle 이란?
buildscript {
ext {
springBootVersion = '2.1.7.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
build.gradle 맨 위에 위치할 코드들이다.
프로젝트의 의존성 관리를 위한 설정이다.
ext라는 키워드는 build.gralde에서 사용하는 전역변수를 설정하겠다는 의미이다.
여기서는 springBootVersion 이라는 전역변수를 설정하고 그 값을 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()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
repositories는 각종 의존성(라이브러리)들을 어떤 원격 저장소에서 받을지를 정한다.
mavenCentral, jcenter 둘다 많이 사용한다.
mavenCentral의 라이브러리 업로드 난이도가 높아, 이 방법이 비교적 간단한 jcenter를 사용하고 있으며, jcenter에 라이브러리 업로드를 하면 mavenCentral에도 업로드 할수 있도록 자동화를 할 수 있어 jcenter를 많이 쓰는 추세이다.
dependencies는 프로젝트 개발에 필요한 의존성들을 선언하는 곳이다.
여기서는 'org.springframework.boot:spring-boot-starter-web' , 'org.springframework.boot:spring-boot-starter-test'를 받도록 선언되어 있다. 단 특정 버전은 명시하지 않아야 위의 선언한 버전을 따라간다!!
위의 코드를 다했으면 build.gradle에 가서 빌드한다.
buildscript {
ext {
springBootVersion = '2.1.7.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
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.jojoldu.book'
version '1.0-SNAPSHOT-'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
책의 내용을 그대로 따름