프로젝트 생성

프로젝트 구조

Untitled

  1. .idea

  2. Gradle

  3. src

  4. [중요!] build.gradle

    자세히

    설정이 변경되면 코끼리를 눌러서 적용을 해줘야합니다. 그래야 라이브러리 같은게 변경이 됩니다.

    plugins {
    	id 'org.springframework.boot' version '2.5.6' //스프링 부트 버전이 2.5.4
    	id 'io.spring.dependency-management' version '1.0.11.RELEASE' //의존관계 관련된 부분 설정
    	id 'java' //자바 언어
    }
    
    group = 'hello' //적어준대로 hello
    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = '11' //자바 버전 11
    
    repositories {
    	mavenCentral()
    }
    
    dependencies {
      implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' //HTML 만드는 템플릿 엔진
    	implementation 'org.springframework.boot:spring-boot-starter-web' //web 프로젝트 선택한 것
    	testImplementation 'org.springframework.boot:spring-boot-starter-test' //test 관련된 라이브러리
    	//testImplementation('org.springframework.boot:spring-boot-starter-test') { //test 관련된 라이브러리
      //      exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
      //}
    }
    
    test {
    	useJUnitPlatform()
    }
    
    1. plugins

      • 설정 관련 정보들이 플러그 인으로 들어갑니다.
      • Gradle은 버전 설정하고 라이브러리 땡겨온다 정도만 이해하면 됩니다.
    2. repositories

      • 아래의 라이브러리를 다운 받아야 하는데 다운 받는 곳인 mavenCentral 사이트를 설정해 준 것입니다.
    3. dependencies

      • 프로젝트 개발에 필요한 의존성들을 선언하는 곳

      그냥 만들면 testImplementation 'org.springframework.boot:spring-boot-starter-test'처럼 나오는데 주석친 부분으로 안바꿔도 테스트 실행하는데 문제는 없다.

      <aside> ❗ 스프링 부트 2.2부터 디폴트로 junit5( jupiter ) 사용합니다.

      vintage는 junit4에 호환되는 버전인데 junit5를 쓰기 때문에 junit4에 대한 버전을 exclude 해버린 것입니다.

      </aside>

프로젝트 실행

🌟 [TIP]

Gradle 모드에서 IntelliJ 모드로 변경

인텔리제이로 바로 실행하기 때문에 좀 빠름