简体   繁体   中英

Spring Boot XML Configuration Option

Is it possible to use XML configuration with Spring Boot. If so , which approach is preferable - xml or annotation & why?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM