Avi
Avi

Reputation: 21760

Disadvantages of using Spring's @Configuration class

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.

Upvotes: 2

Views: 1119

Answers (1)

franksort
franksort

Reputation: 3143

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.

Upvotes: 2

Related Questions