[Spring] Spring Gradle Dependency 키워드 정리

HEESEO·2024년 4월 30일

spring

목록 보기
4/5

dependency options

  • implementation
    • 프로젝트의 컴파일 시간과 실행 시간 모두에 의존성 추가
      dependencies {
          implementation 'org.springframework.boot:spring-boot-starter-web'
      }
      
  • api
    • implementation과 유사하지만, 프로젝트에 의해 노출되어 해당 프로젝트를 의존하는 다른 프로젝트에서도 사용할 수 있게 함
      dependencies {
          api 'org.springframework:spring-context'
      }
      
  • compile
    - 모든 모듈을 재빌드
  • compileOnly

    • 컴파일 시간에만 필요한 의존성 추가, 실행시간에는 포함되지 않음
    • 라이브러리가 컴파일 시에 참조된다
      dependencies {
          compileOnly 'javax.servlet:javax.servlet-api'
      }
      
  • runtimeOnly

    • 실행시간에만 필요한 의존성 추가, 컴파일 시간에는 포함되지 않음
      dependencies {
          runtimeOnly 'mysql:mysql-connector-java'
      }
      
  • testImplementation

    • 테스트 컴파일 시간과 실행 시간에만 필요한 의존성 추가, 주로 단위 테스트나 통합테스트를 위한 라이브러리
      dependencies {
          testImplementation 'org.springframework.boot:spring-boot-starter-test'
      }
      

    api, compile

    api, compile은 같은 역할을 하는데, gradle은 api나 compile 사용하는 것을 권장하지 않는다.

0개의 댓글