spring with XML configuration = ugly

brianmanahan

Lifer
Sep 2, 2006
24,586
5,991
136
it's been years since i did spring with manual XML instead of the automated annotations

just had to slog through it tonight, and oh my gosh

someone shoot me!
 

purbeast0

No Lifer
Sep 13, 2001
53,537
6,364
126
i've never had to set up spring before, every project i've been on, it's already set up. and i've been using groovy, and if you add a new file in the "services" directory structure and just end the class/file name with "Service" it automatically makes it injectable.
 

brianmanahan

Lifer
Sep 2, 2006
24,586
5,991
136
yeahhh i should really see if i can rewrite this whole thing in grails

at the very least i'm gonna change it to annotation-driven DI, so i don't hurt myself
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
I've moved to Java configuration with annotations. it's so much cleaner. The best part is that it's easier for the tools to show you usages of things. IntelliJ did a decent job understanding Spring XML but other code searching tools did not.
 

brianmanahan

Lifer
Sep 2, 2006
24,586
5,991
136
i finally got this thing set up to at least allow new beans to be wired with @Component

too much of a pain to convert all the old stuff from XML to annotations, but maybe someday when i'm really bored
 

Cogman

Lifer
Sep 19, 2000
10,284
138
106
Dagger 2 is really nice. I'm loving it (we just switched our projects from Guice to Dagger). No more days wasted because of some unknowable injection bug.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Dagger reminds of the dependency injection framework I used in C# projects a long time ago. It had the same basic import/provide mechanism.
 

slugg

Diamond Member
Feb 17, 2002
4,723
80
91
Spring is tried and true. Yea, the XML context configuration is archaic, but you did the right thing by switching new development to annotation-driven. Once you're at that point, who cares. ;)

I never liked Guice. I used it with Gin in a GWT based project and boy, was that miserable. Maybe it was Gin and GWT that made it such a horrible experience? It made me love Spring that much more...
 

brianmanahan

Lifer
Sep 2, 2006
24,586
5,991
136
yep, once i got to annotations everything became easy again

spring is weird like that. one or two days of intense springification, then don't need to touch it for another 6-12 months because it just works.