samedi 4 avril 2015

Access custom annotations from other classes in Spring 4

I'm still a beginner at Spring, and am learning about custom Annotations as qualifiers. Can you access custom annotations created in another class?


Creating my annotation:



public class Annotations {
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD,
ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface ChocolateChip{ }
}


Declaring my Bean



@Bean
@Dessert.Annotations.ChocolateChip
public Dessert ChocolateChipBrownie(){
Brownies brownie = new Brownies();
brownie.hasChocolateChips(true);
return brownie;
}


It's not recognizing the Annotations Class and I don't know why. I've tried importing the class but no luck. When I move the declaration into my config class it works fine so the problem isn't with my creation of the annotation.


Any ideas?


Aucun commentaire:

Enregistrer un commentaire