spring - 他们是否有任何替代方法可以将资源过滤与 Maven 一起用于 Spring Boot 应用程序?
问题描述
我正在开发一个使用 Maven 作为构建工具的 Spring Boot 应用程序,我试图在其中使用 Maven 的资源过滤。它似乎不起作用,因为它适用于其他春季项目。我怎样才能实现它?
我在 pom.xml 中使用 spring-boot-starter 作为父级。我在 src/main/resource 文件夹中有 myconfig.properties 文件。我在 myconfig.properties 文件中有如下属性之一:
prop.first=@project.version@
这里 @ 是 spring-boot 默认令牌过滤器,应该使用它来代替 $。
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/>
</parent>
<version>19.6.0</version>
......
<build>
.....
<resource>
<directory>/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/myconfig.properties</include>
</includes>
</resource>
.....
</build>
.....
</project>
由于我的“project.version”是 19.6.0,所以在使用 maven 构建时,我期望 myconfig.properties 文件中的 prop.first 为:
prop.first=19.6.0
但实际上,该属性永远不会被替换,并且在文件中仍然与以下内容相同:
prop.first=@project.version@
我在文档中的某处读到了 Maven 过滤不适用于 Spring Boot 中的 src/main/resources 。虽然与 maven 相同的过滤适用于 spring-boot 以外的其他类型的项目,但在我的情况下,进行资源过滤的替代方法是什么?
解决方案
推荐阅读
- spring - 控制器级别日志中未显示跟踪 ID(Spring 引导、Jaeger 配置)
- docker - Kibana UI 未启动,但容器已启动并正在运行
- elasticsearch - 搜索相隔不到 X 分钟的 2 个 ES 条目
- linux - Authenticate to Azure with certificate from Linux
- python - 为什么静态变量会改变?
- python - ModuleNotFoundError:没有名为“my_module”的模块
- excel - VBA代码中的语言识别问题
- react-native-flatlist - 为什么项目周围有花括号?
- python - SQLAlchemy bulk_insert_mappings 不返回主键
- c# - IdentityServer4 需要配置密钥材料但存在证书