java - spring.profiles.active 在 spring boot 应用程序中不

我已经在 J​​ava 类中创建了这样的配置文件,

@Profile(value = "cache")
public class MapCache {
....
}

当使用 spring.profiles.active 时,这些配置文件不会被激活,但如果我使用 spring.profiles.include 配置文件工作正常。

我想通过在 application.properties 中添加的属性激活配置文件

注意:应用程序在独立的 jetty 实例中运行。

任何提示都会很棒。

最佳答案

要通过注释激活配置文件,您需要 @ActiveProfile("profileName")@Profile 注释用于将对象标记为配置文件的成员。

关于java - spring.profiles.active 在 spring boot 应用程序中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64812810/

相关文章:

html - 将垂直对齐设置为中间不能应用于复选框

c# - if else 语句简化以提高可读性

c# - EF Core EnsureDeleted 抛出 "failed to login wit

python - 有没有办法在 python 列表中切换元素?

php - 元素临 : Change or remove category/tag/author p

perl - 可能对未定义的取消引用数组进行迭代是错误还是功能?

c# - 是否可以在不复制的情况下为多个组件创建一个 Blazor 范围的 CSS 文件?

html - React Material UI-制作一个按钮打开文件选择器窗口

c++ - 如何在 C 中循环 if 语句

javascript - Alpine JS 表格数据绑定(bind)