Categories
Spring Spring Core

Generics as Auto-wiring Qualifiers

When we are using more than one implementation for a Type, we use @Qualifier annotation as explained in this article. We don’t want to use @Qualifier annotation when using Generics as shown in the below example. Step 1 : Create Maven project and name it as GenericsAsQualifiers and copy below dependencies in pom.xml file. Step […]

Categories
Spring Spring Core

Custom Qualifier Annotation

In this article I’m going to explain how to create customized Qualifiers in spring with example code. Instead of using @Qualifier annotation with name as a parameter everywhere, you can customize the Qualifier annotation for you based on the nature of your application. For Example : Mine is a Course management application for colleges. Every […]

Categories
Spring Spring Core

Dependency Injection with @Resource annotation

Key Terms As like Autowired annotation Resource will resolve and inject dependencies.  Unlike Autowired annotation, it will search by Name. Means, It will take Field Name and Setter-Method parameter name to resolve dependencies. Name or ID of the Bean should be provided in XML or @Bean configuration. XML <bean id=”…” class=”…”></bean> @Bean @Bean(“…”) You can […]

Categories
Spring Spring Core

Spring Qualifier Annotation

Generally Autowired annotation will resolve dependencies based on the Type. If you are having only one Class implementing an interface, then Spring will make use of the Class implementation to resolve dependency. But, in most of the scenarios we have more than one Implementation classes for an Interface. If you use @Autowired in this case, […]

Categories
Spring Spring Core

Auto-wiring with Example

In Spring you can Inject Dependencies either in the form of XML or Annotation or Java Code. In this Article we are going to look at how Injection made possible using Autowired annotation and different possible types of Autowiring in Spring with working examples. Auto-wiring in Spring Types Autowiring by Constructor Autowiring by Setter-Method Autowiring […]