Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java json文件的Maven资源过滤_Java_Json_Maven - Fatal编程技术网

Java json文件的Maven资源过滤

Java json文件的Maven资源过滤,java,json,maven,Java,Json,Maven,在我当前的项目中,我有一个子模块,它使用maven exec插件运行一个测试服务,该服务从resources/testResources文件夹之外的位置提取配置文件 我需要使用过滤将环境变量注入到一些配置文件中。这适用于其中一个文件.properties文件,但不适用于另一个文件.json。在后一种情况下,它只是将变量留在json文件中。这两个文件在筛选的目录中紧挨着 下面是子模块中的筛选代码段: <build> <finalName>${artifactId}<

在我当前的项目中,我有一个子模块,它使用maven exec插件运行一个测试服务,该服务从resources/testResources文件夹之外的位置提取配置文件

我需要使用过滤将环境变量注入到一些配置文件中。这适用于其中一个文件.properties文件,但不适用于另一个文件.json。在后一种情况下,它只是将变量留在json文件中。这两个文件在筛选的目录中紧挨着

下面是子模块中的筛选代码段:

<build>
  <finalName>${artifactId}</finalName>
  <testResources>
    <testResource>
      <filtering>true</filtering>
      <directory>../etc</directory>
    </testResource>
  </testResources>
简化项目结构:

  • 计划
      • config.properties
      • config.json
    • 子模块
      • pom.xml
子模块肯定正在加载这两个文件,但只过滤.properties文件


作为一个json文件,它是否有什么特别之处,可以防止对它进行过滤?对此能做些什么

不管它值多少钱,我最终还是成功了。我发现我必须直接列出要包含的文件,以便对其进行处理(这已经很长时间了,希望这是正确的解决方案):


${artifactId}
真的
../等
config.json
config.properties
...

除了编写自己的Maven插件,是的,这是正确的解决方案。感谢您回来告诉我们您的解决方案。
{ "customMappings" :
    { "tag:example.com:/vagrant/" : "file:${VAGRANT_CWD}" }
}
<build>
  <finalName>${artifactId}</finalName>
  <testResources>
    <testResource>
      <filtering>true</filtering>
      <directory>../etc</directory>
      <includes>
        <include>config.json</include>
        <include>config.properties</include>
      </includes>
    </testResource>
  </testResources>
...