gradle - WAR 文件中的 JAR 文件的属性在运行时没有被拾取?
问题描述
我是一个 DevOps 人,不是一个开发者,所以我可能无法正确地表达这篇文章,但这里有。
我们使用 Gradle 来构建。我知道这是一个非常旧的版本,但这就是我们所拥有的。更新版本可能会打开不同的蠕虫罐。
$ ./gradlew --version
------------------------------------------------------------
Gradle 2.9
------------------------------------------------------------
Build time: 2015-11-17 07:02:17 UTC
Build number: none
Revision: b463d7980c40d44c4657dc80025275b84a29e31f
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_181 (Oracle Corporation 25.181-b13)
OS: Mac OS X 10.13.6 x86_64
我有 2 个模块,module-core 和 module-app,module-app 依赖于 module-core,所以我在 module-app/build.gradle 文件中有这个
dependencies {
compile project('module-core')
...
}
module-core 具有以下属性文件
module-core/src/main/resources/application-production.properties
并具有以下键/值对
key1=value1
key2=value2
module-app 具有以下属性文件,并且是EMPTY。请注意路径的细微差别 - 它在路径中有一个“配置”子目录,模块核心没有!
module-app/src/main/resources/config/application-production.properties
module-app 然后具有以下 XML 文件,该文件指示(从开发人员告诉我的内容)每个属性文件中的键/值对如何聚合
module-app/src/main/resources/admin-properties.xml
并有以下节
<beans profile="production">
<context:property-placeholder
location="classpath:application.properties,classpath:config/application.properties,classpath:application-production.properties,classpath:config/application-production.properties"
ignore-unresolvable="true"/>
</beans>
在我做了一个之后
$ ./gradlew clean build -x test
module-app.war 中有一个 module-core.jar 文件
$ cd /path/to/module-app.war
$ tar -xvf module-app.war
$ cat ./WEB-INF/lib
$ tar -xvf module-core.jar
$ cat application-production.properties
它具有正确的值。
key1=value1
key2=value2
然而,当我们通过 tomcat 运行我们的 module-app.war 应用程序时,这些值不会被拾取,如日志中所示。
我错过了什么?
解决方案
推荐阅读
- javascript - Javascript在下拉列表上设置默认值不起作用
- python - Python中的格式化列表
- python - 如何使用 dialogflow python api 在 shell(最好是 repl.it)中制作文本机器人?
- angular - 从 Handsontable 上更改的行中获取数据(数据,列号,行号)
- android - 如何将底部导航视图颜色更改为使用 xml 创建的自定义颜色?
- javascript - 我可以知道为什么我的 ajax 被调用了两次吗?或者实际上是正常的?
- r - 在 R、igraph 的网络图中添加工具提示和图例
- vue.js - vue js 中的 process.env.BASE_URL 是什么?
- swift - RxSwift,如何更温和地使用 NotificationCenter?
- python - 如何在列表和字符串中约会约定?