【发布时间】:2018-05-30 10:07:32
【问题描述】:
有人可以指导我从哪里开始这项任务吗?
在部署到 jboss 时,我只需要排除 spring-boot-starter-tomcat。
我想它看起来像:
dependencies {
compile("org.springframework.boot:spring-boot-starter-web"){
if(getProperty "spring.profiles.active" == "qat")
exclude module: "spring-boot-starter-tomcat"
}
testCompile('org.springframework.boot:spring-boot-starter-test')
}
使用上面的示例,我得到一个错误:
Could not get unknown property 'spring.profiles.active' for DefaultExternalModuleDependency{group='org.springframework.boot', name='spring-boot-starter-web', version='null', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency.
也许我可以创建一个自定义任务来在该任务上设置spring.profiles.active。帮助!
【问题讨论】:
-
spring.profiles.active在哪里定义? -
@ToYonos,它在 src_server/main/resources/application.yml 中。
-
所以
getProperty "spring.profiles.active"不是真的吗?这不是读取application.yml的方法? -
上面的示例代码出现错误。我已编辑问题以包含错误消息。
-
您正在创建 WAR 文件吗?请注意,Gradle 对 application.yml 文件一无所知。另外,您确定应该在哪里定义
spring.profiles.active吗?据我记得,application.yml 允许您根据spring.profiles.active的值指定不同的值。
标签: java gradle build.gradle