javaspringannotationsjsr330

Is there a JSR-330 equivalent of Spring's @Value annotation?


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?


Solution

  • 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.