자바극혐
프로젝트 환경
- Java 11 (JDK 11.0.11)
- Gradle 7.1
gradle 프로젝트 생성시 만들어지는 초기 builde.gradle
plugins {
id 'java'
}
group 'com.project.spring'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
test {
useJUnitPlatform()
}
책에서 수정한 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.project.spring'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
❗️ERROR
> Could not find method compile() for arguments [org.springframework.boot:spring-boot-starter:spring-boot-starter-web] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
💡
compile 은 deprecate 되었다. implementation 을 사용하자.
compile -> implementation
testCompile -> testImplementation
참고
내 환경에 맞게 수정한 builde.gradle
buildscript {
//build.gradle 에서 사용하는 전역변수 설정
ext {
springBootVersion = '2.1.7.RELEASE'
}
repositories {
mavenCentral()
}
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.project.spring'
version '1.0-SNAPSHOT'
sourceCompatibility = 11
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
- spring-boot-starter-web 을 내려받으면, 의존관계가 있는 라이브러리도 함께 다운로드 된다.
- spring-boot-starter-tomcat
- spring-webmvc
- 라이브러리들의 hierarchy 는 Gradle 탭의 Dependencies 에서 확인할 수 있다.
'WEB > Java' 카테고리의 다른 글
static, final 키워드에 대하여 - ① static 키워드 (0) | 2022.02.08 |
---|---|
스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 03-1 JPA 적용 (0) | 2022.02.02 |
스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 02-2 lombok 적용 (0) | 2022.01.22 |
스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 02-1 테스트코드 작성 (0) | 2022.01.16 |
Java 개발환경 설정하기 (Mac/IntelliJ) (1) | 2021.12.17 |