2

I work for a company with a code-base of millions of lines and hundreds of modules. Our Spring configurations, all of the beans definitions and wirings, are defined in XML files.

I find it very hard to use XMLs - it's not debuggable, not-type safe, requires a lot of ctrl+f and so on. I want to switch to use @Configuration classes instead.

I see almost exclusively advantages, aside from the fear that when we'll use code to configure our wiring it may be abused. I'm trying to find out what are the disadvantages, aside from abusing this feature, that I should consider when taking this step.

Avi
  • 21,182
  • 26
  • 82
  • 121

1 Answers1

2

Basically, it's really a matter of convenience. Spring always made sure that all of their APIs integrate as easily as possible. You can migrate to @Configuration and use XML beans and vice-versa quite easily.

I can think of only two main disadvantages:

  1. As you said - abuse of the system.
  2. An issue I found while migrating is the inability to use abstract beans. In XML, marking a bean as abstract ie. <bean id="someBean" abstract="true">...</bean> will make it a template--but you can't use this template when migrating a bean that has parent="someBean" easily. You'll have to copy the abstraction from the XML.
franksort
  • 3,093
  • 2
  • 19
  • 27
  • Well, although late, just found a problem with @@Configuration and Prototype beans, see [PrototypeBeans do not get Autowired setters correctly](https://stackoverflow.com/questions/63998293/spring-not-calling-autowired-setters-in-prototype-beans), to be aware of. – tonio Sep 24 '20 at 15:44