Explanation with example for @Qualifier

Let’s say we have two beans qualified to be injected then we go for this.

Change code as below :


Now we will see how we can inject primitives from property files.

Change spConfig.xml as below.

  • We need to inform spring where is out properties file located.

  • Create property file in resources folder

  • Use annotation @value for injecting values.

  • Value may be multiple [comma separated ] or single

  • Client for invocation

  • We are using this for DB Connection in this case.

Spconfig.xml


DB.properties


DBUtil.java



Ready for structured training?

Learn Java Full Stack with real projects

Live classes, practical projects, interview preparation and placement support in one guided programme.

View Java Full Stack Course Book Free Demo