Tag: springboot

  • @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 almost in the same way you use the other annotations used to inject dependencies. Using in-field injection and set methods is possible, but constructors are…

  • 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 specify the beans you need to be created first in the @DependsOn annotation parameters. This annotation is used when a bean does not explicitly depend…

  • 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 name, @Qualifier helps Spring determine which bean to inject. The @Primary annotation will help Spring decide which of those same types of beans it should…

  • 3 Ways to Use the @Lazy Annotation in Spring

    Does your Spring application take too long to start? Maybe this annotation could help you. This annotation indicates to Spring that a bean needs to be lazily initiated. Spring will not create this bean at the start of the application. Instead, it will create it only when the bean is requested for the first time.…