Skip to content
Advertisement

Tag: annotations

Should I annotate pojo class with @Component?

I searched whether I should annotate POJO with @Component or not. It seems like it is recommended not to annotate pojo. Here is my OrderStatusMnemonic Configuration class that reads a txt file: OrderStatus POJO: Since I am autowiring OrderStatus POJO class I am getting error: Consider defining a bean of type ‘com.spectrum.sci.osm.orderstatus.OrderStatus’ in your configuration. Answer Your OrderStatus as it

@PostConstruct and @PreDestroy annotations do not work

I have TennisCoach class: And such main class: Expected output is: Inside default constructor Inside postconstructor DailyFortune Practice your backhand volley Inside predestroyer But I get this: Inside default constructor DailyFortune Practice your backhand volley It seems like @PostContruct and @PreDestroy annotations do not work correctly. I cannot find the reason of my problem. Answer If you use java 9+

How to get annotation parameter in annotation processor

I’m writing my own annotation processor and I’m trying to get parameter of my annotation like in the code below in process method: What I get is An exception occurred: javax.lang.model.type.MirroredTypesException: Attempt to access Class objects for TypeMirrors [] during build. Anyone know how to get annotation data? Answer The documentation on the getAnnotation method explains why Class<?> objects are

What is the use of @EnableWebSecurity in Spring?

As per the Spring documantation: Add this annotation to an @Configuration class to have the Spring Security configuration defined in any WebSecurityConfigurer or more likely by extending the WebSecurityConfigurerAdapter base class and overriding individual methods: Or As this @EnableWebSecurity depicts, is used to enable SpringSecurity in our project. But my question is that even if I don’t annotate any of

Advertisement