How get working @Value or Environment in a class implementing the Condition/ConfigurationCondition interfaces

▼魔方 西西 提交于 2019-12-02 07:26:57

You have

@Conditional(LocalHostStatusCondition.class)

Spring takes the Class type you've specified and instantiates it to use its matches method. It doesn't consider the instance as a bean, it doesn't perform autowiring on it, nor any @Value processing. The latter are true for BeanFactoryPostProcessor as well.

You can retrieve the Environment from the ConditionContext if you want to. The alternative is to load the properties yourself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!