Reputation: 16992
Is it possible to use XML configuration with Spring Boot. If so , which approach is preferable - xml or annotation & why?
Upvotes: 0
Views: 264
Reputation: 8411
Yes you can can call the SpringApplication.run()
function with an XML file.
You can also include a existing xml using @ImportResource
.
Spring-boot official documentation recommends to use Annotation over XML.
This is opinion driven, IMO One of the biggest advantages of using annotations with spring is ease with which you can define complex beans without searching for different tags you need to use when configured in XML.
One other advantage, I have experienced is when using JPA, it helps you trace the transaction boundaries easier than when configured in xmls.
Upvotes: 3