Tag: technology

  • Understanding @Repository in Spring

    What is @Repository? This is a class-level annotation that indicates that the Class’s purpose is to store, search, retrieve, update, and delete objects. It has a special role when dealing with databases. Why is it important? How to use @Repository Define an interface, annotate with @Repository, and extend one of those interfaces: JpaRepository, CrudRepository, or PagingAndSortingRepository. This…

  • What is @Service In Spring?

    This is a class-level annotation that is a specialization of @Component designed to handle business logic. It will turn your class into a Spring-managed bean. Why is it important? By using this annotation, you are implementing a separation of concerns by placing the business logic in a specific layer, thereby improving code readability. How to…

  • @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…

  • Using @Qualifier to Resolve Bean Conflicts in Spring

    When working on a Spring project, you might encounter a situation where you have multiple bean implementations for the same type. This can cause an error because Spring doesn’t know which bean to inject. To solve this, we use the @Qualifier annotation. The Problem Let’s say you have an interface MessageService that your application uses…

  • How @AliasFor Simplifies Annotations usage in Spring

    This annotation is an annotation that allows you to create an alias for an attribute in an annotation. These attributes have the same function. The idea is to avoid confusion when multiple attributes can be used for the same purpose Maybe this is the first time you have seen it. Spring uses this annotation in…

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

  • Understanding @Autowired in Spring: A Comprehensive Guide

    Introduction The @Autowired annotation is one of the most common annotations when working with Spring. Its objective is simple: to tell Spring to inject a dependency bean into our beans. In other words, it will pick an instance of a bean from the Spring IoC (Inversion of Control) container and set it into our components.…

  • 12 Ways to Use the @Value Annotation in Spring for Flexible and Maintainable Applications

    You may already be familiar with @Value annotation from Spring. This annotation allows you to inject some properties into your beans. But there’s a lot of ways you could do that. And maybe you are not familiar with all of them. This article will show you many ways to work with @Value and some new…

  • Specification-Based Testing: A Developer’s Secret Weapont

    One quick story: I was adding a new feature that needed an API client created by another developer. The API required three inputs: ID, country code, and phone number. I followed this specification, made a test, and all seemed good. But when I updated my code later before deploying. I found out the other developer…