java - Spring Condition not able to read value from property file -


i trying implement spring condition org.springframework.context.annotation.conditionas follows:

public class apiscanningdecisionmaker implements condition {     @override    public boolean matches(conditioncontext context, annotatedtypemetadata metadata) {      // not able read property "swagger.scanner.can.run". null.     string canrunflaginstr = context.getenvironment().getproperty("swagger.scanner.can.run");    // ignore rest of code.    } } 

however, shown in above code, when read property "swagger.scanner.can.run" null. in property file have set "swagger.scanner.can.run=false".

i tried use @value("${swagger.scanner.can.run}") returns null. when put debug in method can see being called.

just sake of completion using apiscanningdecisionmaker follows:

@configuration @enableswagger @conditional(apiscanningdecisionmaker.class) public class customswaggerconfig {   // ignore rest of code } 

is there reason why "swagger.scanner.can.run" being retrieved null?

maybe spring doesn't know file ?

this can fix on annotated class @value("${swagger.scanner.can.run}")is used :

@propertysource(value="classpath:config.properties") 

regards,


Comments