Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a Java DI container that works in a similar way to the most excellent Castle.Windsor container on the .NET side?

The Java containers I've had a look at all seem to rely on annotations (Guice) within my services, which I don't dig all that much - I'd like to go POJO all the way if possible. Spring on the other hand can do without the annotations, but it requires a lot of XML. XML configuration != maintainability.

One of the really nice things about Castle.Windsor is the wiring you're able to set up in code with Installers, auto wiring based on naming conventions and whatnot.

Ideally the container should also support lifecycle management and configuration; i.e. registering components as transient, singleton, pooled etc.

Another bonus would be support for interceptors.

Any tips would be greatly appreciated.

share|improve this question
up vote 0 down vote accepted

The most popular DI containers in Java are PicoContainer, Guice and Spring, I'm not sure how they compare to the .NET one you mentioned.

share|improve this answer
After taking a closer look at PicoContainer it seems to be the one (out of the three you mentioned) that strikes the best balance between my requirements / what I'm used to. Thanks for the tip. – Ciddan Mar 29 '12 at 9:06

Try Spring's Javaconfig- it can be used in several ways, I prefer to not put annotations in the classes I'm using and just writing a context class with the @Config and @Bean annotations. It does autowiring (although I prefer not using it).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.