Springboot 공부하기!

[Springboot] InteliJ로 Springboot 시작하기

hyer!! 2021. 3. 22. 17:33

1. Create New Project 버튼을 클릭한다.

 

2. gradle 프로젝트를 생성한 후 Next 버튼을 클릭한다.

 

3. GroupId와 ArtifactId를 등록한 후 Finish 버튼을 클릭한다. 여기서 ArtifactId는 프로젝트의 이름이 된다.

 

4. gradle 프로젝트를 springboot 프로젝트로 변경하기 위해 build.gradle 파일을 수정한다.

//https://start.spring.io/
//프로젝트의 플러그인 의존성 관리를 위한 설정
buildscript {
    
    ext {
    //ext : build.gradle에서 사용하는 전역변수를 설정하겠다라는 의미
    // springBootVersion 전역변수를 생성하고 그 값을 '2.1.7.RELEASE' 로 하겠다라는 의미
        springBootVersion = '2.1.7.RELEASE'
    }
    repositories {
    //repositories : 각종 라이브러리들을 어떤 원격 저장소에서 받을지 정함
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

//플러그인 의존성들을 적용할 것인지를 결정하는 코드
//4개의 플러그인은 자바와 스프링부트를 사용하기 위한 필수 플러그인이다.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management' //스프링 부트의 의존성들을 관리해 주는 플러그인(반드시 추가 해야됨)



group 'com.hr.springBootService'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    /*testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'*/
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile ('org.springframework.boot:spring-boot-starter-test')
}

test {
    useJUnitPlatform()
}

- mavenCentral : 이전부터 많이 사용하는 저장소지만, 본인이 만든 라이브러리를 업로드하기 위해서는 많은 과정과 설정 필요

- jcenter : 라이브러리 업로드가 비교적 간단함