I'm using Spring and Jersey in my application which is running under Tomcat. And it seems that spring cannot inject values into fields annotated by @Value in classes which are being managed by servlet container.
Here is my code:
ContainerRequestFilter:
@Provider
@Priority(Priorities.AUTHORIZATION)
public class AuthorizationRequestFilter implements ContainerRequestFilter {
@Value("${prop.value}")
private String value;
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
//...
}
}
applicationContext.xml
<context:property-placeholder
location="classpath:properties/app.properties"
ignore-resource-not-found="true"
system-properties-mode="OVERRIDE"/>
<context:annotation-config/>
<bean id="authorizationRequestFilter" class="com.test.filters.AuthorizationRequestFilter"/>
Value field is always null. However @Autowired annotations seem to work fine in the same case. So is there any way to inject property values into such classes?
Aucun commentaire:
Enregistrer un commentaire