사용자 도구

사이트 도구


springframework:springboot:gradle

문서의 이전 판입니다!


SpringBoot and Gradle

Dependency Version Override

의존 라이브러리의 버전을 다른 것으로 바꾸고자 한다면 property를 변경하면 된다.

// 하이버네이트 버전
ext['hibernate.version'] = '5.2.14.Final'

BootRun

Debug Mode

bootRun {
    if (project.hasProperty("bootDebug")) {
        jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"]
    }
}
 
// suspend=y는 JVM이 뜰 때 Remote Debugger가 접속될 때까지 기다린다.
// 실행 후 바로 종료하는 명령행 애플리케이션의 경우 무조건 y
# -PbootDebug 프라퍼티를 지정하면 디버그 모드로 뜬다.
./gradlew bootRun -PbootDebug

Application Arguments

bootRun {
    if (project.hasProperty('args')) {
        args project.args.split(',')
    }
}

위와 같이 설정하고, 아래와 같은 형태로 실행한다.

./gradlew bootRun -Pargs=param1,param2,...

Property Override

Environment Variable 사용

SPRING_PROFILES_ACTIVE=test gradle clean bootRun

// on Windows
SET SPRING_PROFILES_ACTIVE=test
gradle clean bootRun

Gradle 에 System Property 그대로 계승

bootRun.systemProperties = System.properties

새로운 bootRun Task 로 만들어버리기

  • 새로운 bootRun 태스크를 만들고, 거기에 각종 기본 설정 추가
task bootRunDev(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') {
    group = 'Application'

    doFirst() {
        main = bootJar.mainClassName
        classpath = sourceSets.main.runtimeClasspath
        systemProperty 'spring.profiles.active', 'dev'
    }
}
springframework/springboot/gradle.1543377314.txt.gz · 마지막으로 수정됨: 2018/11/28 12:55 저자 kwon37xi