Spring Condition not able to read value from property file

后端 未结 4 928
耶瑟儿~
耶瑟儿~ 2021-01-11 13:24

I am trying to implement Spring Condition org.springframework.context.annotation.Conditionas follows:

public class APIScanningDecisionMaker impl         


        
4条回答
  •  庸人自扰
    2021-01-11 14:00


    The object of class implementing "Condition" is created via constructor from Spring, so you can not inject values using @Value annotation. You can do something like below in your code:

    @Override        
    public boolean matches(
    ConditionContext arg0, 
                AnnotatedTypeMetadata arg1) {       
            String prop = conditionContext.getEnvironment()
                     .getProperty("arg0");   
    //further code   
         }    
    

提交回复
热议问题