스프링 부트와 AWS로 혼자 구현하는 웹 서비스 - 예스24
가장 빠르고 쉽게 웹 서비스의 모든 과정을 경험한다. 경험이 실력이 되는 순간!이 책은 제목 그대로 스프링 부트와 AWS로 웹 서비스를 구현한다. JPA와 JUnit 테스트, 그레이들, 머스테치, 스프링
www.yes24.com
*위의 책을 따라 학습한 것을 정리한 내용입니다
dependencies에 직접 추가하는 방법에 대해 알기 위해 수동으로 전환하였다.
Gradle Project -> Spring Boot로 전환
(처음부터 이니셜라이저로 프로젝트를 만들 수 있다. https://start.spring.io/)
코드
build.gradle 파일에 기초적인 설정만 되어있는 상태
plugins{
id 'java'
}
group 'com.jojoldu.boot'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit' version:'4.12'
}
위 코드를 아래와 같이 바꾼다.
(수정 후 refresh 후 의존성 주입 확인 하기)
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'
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
코드 설명
buildscript {
ext {
springBootVersion = '2.1.7.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
ext는 전역변수를 선언한다는 의미이다.
repositories는 의존성(라이브러리)들을 어떤 원격 저장소에서 받을지 지정하는 곳이다.
mavenCentral이 직접 만든 라이브러리 업로드 하는 과정이 복잡해 jcenter와 같이 선언하여 사용하였다.
dependencies는 개발에 필요한 의존성을 선언하는 곳이다.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
'io.spring.dependency-management' 플러그인은 스프링 부트의 의존성들을 관리해 주는 플러그인이다.
위 4개의 플러그인들은 자바 및 스프링 부트를 사용하기 위한 필수 플러그인들이다.
아래와 같은 의미로 사용한다. plugins { } 쪽이 더 최신형.
plugins {
id 'java'
id 'eclipse'
id 'org.springframework.boot'
id 'io.spring.dependency-management'
}
'WORK > STUDY' 카테고리의 다른 글
[Mustache] 화면 역할에 충실한 템플릿 엔진 (0) | 2023.10.26 |
---|---|
[Spring] JPA Auditing(생성/수정시간 자동화) (0) | 2023.10.26 |
[Spring] API 만들기(h2 웹 콘솔 이용하기) (0) | 2023.10.26 |
[Spring] JPA 사용하기 (0) | 2023.10.25 |
[Spring] Controller 작성 및 테스트 (0) | 2023.10.25 |