저는 Spring 프로젝트를 개발 중입니다. 명령 줄에서 자격 증명을로드하고 싶지 않습니다. 나는이 Gradle을 명령을Grale 명령 줄에서 Spring 프로젝트 (Boot가 아님)에 인수를 전달할 수 없습니다.
gradlew build -Dspring.datasource.username=tester
을 실행하기 위해 노력하고있어 나는 봄 프로젝트를 시동 할 때, 프로그램은 중단 점에서 중지와 나는 변수가 선언 여부를 참조하십시오. -D 대신 -P를 사용하려고 시도했지만 여전히 도움이되지 않습니다.
필자는 사용하려고 시도한 bmuschko 플러그인을 사용하여 스프링 응용 프로그램을 원격으로 배포하지만 성공하지는 못합니다. Spring에서 지원하는 System.getProperties() 및 Environment 객체를 사용하여 java 코드 속성을 검사했습니다.
gradlew cargoredeployremote -Dspring.datasource.username=tester
응용 프로그램 속성이 성공적으로로드되었습니다.
중요 : 많은 튜토리얼을 만드는 방법을 보았지만 Spring Boot를 사용하여 Spring에서 선택된 구성 요소 만 사용합니다. 예 : http://nixmash.com/post/passing-arguments-to-spring-boot - bootRun 작업이 없기 때문에 제 경우에는 작동하지 않습니다.
아이디어가 있으십니까? 내 걸음에서 뭔가를 놓치고 있니? 명령에서 제공되는 $ 안에 이름을있는 application.properties에 {}이 다른했다 : 여기
는group 'example'
version '1.0.0'
apply plugin: 'application'
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'com.bmuschko.cargo'
apply plugin: 'org.liquibase.gradle'
compileJava.options.encoding = 'UTF-8'
mainClassName = 'api.optic.config.WebAppInitializer'
sourceCompatibility = 1.8
buildscript {
repositories{
jcenter()
mavenCentral()
}
dependencies{
classpath 'com.bmuschko:gradle-cargo-plugin:2.2.3'
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-RC3'
classpath 'org.liquibase:liquibase-core:3.4.1'
classpath "org.liquibase:liquibase-gradle-plugin:1.2.4"
classpath "mysql:mysql-connector-java:5.1.13"
}
}
project.ext {
springVersion = "4.3.6.RELEASE"
junitVersion = "5.0.0-RC3"
}
repositories {
mavenCentral()
}
dependencies {
compile "org.springframework:spring-core:${springVersion}"
compile "org.springframework:spring-context:${springVersion}"
compile "org.springframework:spring-context-support:${springVersion}"
compile "org.springframework:spring-beans:${springVersion}"
compile "org.springframework:spring-web:${springVersion}"
compile "org.springframework:spring-webmvc:${springVersion}"
compile "org.springframework:spring-orm:${springVersion}"
compile "org.springframework:spring-oxm:${springVersion}"
compile "org.springframework:spring-jdbc:${springVersion}"
compile "org.springframework:spring-test:${springVersion}"
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.38'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.5.6'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.2'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: '2.9.0.pr2'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: '2.9.0.pr2'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.9.0.pr2'
compile 'javax.servlet:javax.servlet-api:3.1.0'
testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
cargo {
containerId = 'tomcat8x'
port = 8080
deployable {
context = 'example'
}
remote {
hostname = 'host.name.com'
username = 'tomcat'
password = 'pass'
}