문제

I'm trying to use JSR-330 annotations with Spring 3.

Is there a JSR-330 equivalent of Spring's @Value annotation for inserting property values? e.g. can I use @Provider in a way that will instruct Spring to inject a property value?

도움이 되었습니까?

해결책

I looked for usages of @Value in a project that is using org.springframework.beans-3.0.5.RELEASE.jar. The annotation is referenced in two places here, AutowiredAnnotationBeanPostProcessor and QualifierAnnotationAutowireCandidateResolver.

In AutowiredAnnotationBeanPostProcessor, the only JSR-330 annotation mentioned is javax.inject.Inject.

public AutowiredAnnotationBeanPostProcessor()
{
    this.autowiredAnnotationTypes.add(Autowired.class);
    this.autowiredAnnotationTypes.add(Value.class);
    ClassLoader cl = AutowiredAnnotationBeanPostProcessor.class.getClassLoader();
    try {
        this.autowiredAnnotationTypes.add(cl.loadClass("javax.inject.Inject"));
        this.logger.info("JSR-330 'javax.inject.Inject' annotation found and supported for autowiring");
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
    }
}

QualifierAnnotationAutowireCandidateResolver makes no mention of JSR-330 annotations.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top