2016년 8월 10일 수요일

Replacing the property token to value

You can replace the token to property value as below.

- src/main/resources

spring.application.name=@applicationName@

- build.gradle

def applicationName = "testApplicatonName"

apply plugin: 'java'
apply plugin: 'spring-boot'

repositories {
    maven { url "http://repo1.maven.org/maven2" }
}

dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
}

buildscript {
    repositories {
        maven { url "http://repo1.maven.org/maven2" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
    }
}

import org.apache.tools.ant.filters.ReplaceTokens

processResources {
    filesMatching('*.properties') {
        filter(ReplaceTokens, tokens: ['applicationName': applicationName])
    }
}


- after building, buildedJar/application.properties

spring.application.name=testApplicatonName

댓글 없음 :

댓글 쓰기