-
Spring Essentials: How to Use the @Bean Annotation for Custom Services
In our application, we have a lot of objects. These objects are components of our application. When we want Spring to create, manage, and inject these objects, they are considered… Read more
-
Spring Framework Essentials: Understanding @ComponentScan
@ComponentScan is an annotation that tells Spring where to find classes annotated as Spring beans. Using this annotation, we can instruct Spring to create beans only for the specified location.… Read more
-
How to Use Spring’s @Profile Annotation for Flexible Configurations
The profile annotation in spring allows you to segregate configurations that are available only in specific environments. If you mark a @Component (and its specializations) or any @Configuration or @Bean… Read more
-
How to Use the @Import Annotation in Spring Framework
The @Import annotation allows you to specify which configurations your Spring application should load. You can think of this annotation as your Java class’s import statements. In this case, it’s… Read more
-
Method security with @Secured Annotation in Spring
This annotation provides a way to add security configuration to business methods. It will use roles to check if a user has permission to call this method. The annotation is… Read more
-
Using the @Lookup Annotation in Spring
The @Lookup annotation is an injection (like @Inject, @Resource, @Autowired) annotation used at the method level. This annotation tells Spring to overwrite the method, redirecting to the bean factory to… Read more
-
@PreDestroy and @PostConstruct in Spring: Managing Bean Lifecycle
These annotations are called at specific moments in the bean lifecycle. They allow you to define methods executed after a bean is created and before the beans are destroyed. Both… Read more
-
@Resource: The Versatile Bean Injection Annotation for Jakarta EE and Spring
This annotation does bean injection, like the @Autowired and @Inject annotations. This annotation is packaged with Jakarta EE and will work on your Spring projects. You can use this annotation… Read more
-
Understanding the @DependsOn Annotation in Spring
Introduction to the @DependsOn Annotation This annotation tells Spring that the bean marked with this annotation should be created after the beans that it depends on are initialized. You can… Read more
-
Understanding @Primary in Spring
If you read my post about the @Qualifier annotation, you have noticed that defining two beans of the same type can be a challenge. By distinguishing it with a qualifier… Read more