'@Value returning the property name instead of value
I have a Controller like this:
public class Controller extends AbstractController {
...
@Value("${application.property.list}")
private Set<String> properties;
...
}
And the application.properties looks like this:
application.property.list = property1,property2,property3,property4
Why the field properties contains the property name "application.property.list" instead of the values?
However, if i create a separated @Component like this one:
@Component
public class AvailableProperties {
private final Set<String> values;
@Autowired
private AvailableProperties(@Value("${application.property.list}") final Set<String> values) {
this.values = values;
}
public Set<String> values() {
return Collections.unmodifiableSet(values);
}
}
Works perfectly by injecting it in the Controller
@Autowired
private AvailableProperties availableProperties;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
