在我当前的项目中,我有一个子模块,它使用 maven exec 插件运行测试服务,该服务从资源/testResources 文件夹之外的位置提取配置文件。
我需要使用过滤将环境变量注入到一些配置文件中。这适用于其中一个文件 .properties 文件,但不适用于另一个 .json 文件。在后一种情况下,它只是将变量留在 json 文件中。这两个文件在过滤目录中彼此相邻。
这是来自子模块的过滤片段:
<build>
<finalName>${artifactId}</finalName>
<testResources>
<testResource>
<filtering>true</filtering>
<directory>../etc</directory>
</testResource>
</testResources>
Run Code Online (Sandbox Code Playgroud)
json文件:
{ "customMappings" :
{ "tag:example.com:/vagrant/" : "file:${VAGRANT_CWD}" }
}
Run Code Online (Sandbox Code Playgroud)
简化的项目结构:
子模块肯定会加载这两个文件,但只过滤 .properties 文件。
它是一个 json 文件有什么特别之处可以防止过滤发生在它身上吗?有什么可以做的吗?
不管它的价值如何,我最终确实让它发挥了作用。我发现我必须直接列出要包含的文件才能对其进行处理(已经很长时间了,所以希望这是正确的解决方案):
<build>
<finalName>${artifactId}</finalName>
<testResources>
<testResource>
<filtering>true</filtering>
<directory>../etc</directory>
<includes>
<include>config.json</include>
<include>config.properties</include>
</includes>
</testResource>
</testResources>
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1024 次 |
| 最近记录: |