Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to define which implementation to execute?

If I have more than 2 implementations of DAO how to define in ServiceImpl that, which implementation should execute when run the program in Spring BOOT?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can use @Qualifier annotation in this case along with @Autowired if you want to specify which bean you want to use.

for eg:-

@Qualifier("Dao1")
@Autowired
private final Dao daoImpl1;

This will make sure that the bean or Dao bean with name Dao1 will only be injected so that you can use it .

You can learn more about this from the below post:

https://www.baeldung.com/spring-qualifier-annotation

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading