spring-boot - Spring Boot 未加载活动的 application.properties 文件
问题描述
我正在使用 Spring Boot 根据此处记录的环境激活配置文件
在大多数情况下,它都有效。但是,我遇到了一个奇怪的情况。我有三个application-{profile}.properties
文件如下:
application-dev.properties
application-uat.properties
application-release.properties
当我将战争文件部署到 uat 时,Spring 正在从发布文件中获取 JDBC 连接。application.properties 文件包含一行 -
spring.profiles.active=uat
如果我将 application-release.properties 文件的名称更改为 application-release.properties.tmp,那么 Spring 将从 application-uat.properties 中获取连接。有任何想法吗。顺便说一句,我正在使用 Spring.Boot 2.2.0-RELEASE
解决方案
解决了!不确定我所做的两项更改中的哪一项解决了这个问题,但就是这样。
- 在阅读 Daniel Olszewski 文章中的评论时,Marcelo Martins 表示,当使用 'spring-boot-starter-parent' 时,无需在 pom.xml 中指定资源过滤,Daniel 进一步证实了这一点。当我使用“spring-boot-starter-parent”时,我将其删除。
为了解决我的问题,我重新插入了它。
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
- 我将 maven 插件升级到 2.2.0.RELEASE
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.0.RELEASE</version>
</plugin>
推荐阅读
- django-models - 序列化多个相关模型
- mysql - Mysql在日期位于日期集中的条件下选择
- vba - 判断是否从特定邮箱发送
- wordpress - 如何实施 Select2 下拉菜单 / WooCommerce / 复合产品
- spring-boot - SpringBoot gradle 插件抱怨“未解决的参考:providedRuntime”
- cakephp - 如何对“列表”查找器查询进行排序?结果未按定义的顺序显示
- python - 使用 sklearn columntransfromer 时解包错误
- powermock - 在 testCompileJava 期间找不到 powermock-api-support-sources.jar
- reactjs - GET后商店不更新
- java - 为什么我的 shell 脚本的输出没有在控制台中打印?