Reputation: 369
I am trying to get this @Value running in an @Embeddable pojo class, but the value ist always false. All application.properties files are filled correctly. Is it maybe just not possible, because it's no srvice/ controller/ configuration?
@Embeddable
public class WebDestination implements Serializable {
@Value("${property.example}")
private boolean example;
public boolean isExample() {
return example;
}
public void setExample(boolean example) {
this.example= example;
}
}
Upvotes: 0
Views: 324
Reputation: 2262
You can only inject property value using @Value("${property.example}")
in components that are managed by Spring container (classes that are annotated with @Service
, @Controller
, @Component
, @Configuration
and ...), you can't use it anywhere else.
Upvotes: 6