Monthly Archives: December 2010

Spring – Usage of @Primary annotation or attribut for inject default bean instances

For using dependency injection with Spring 3.0, several ways exists. You can use the annotation based way with the annotations @Service, @Repository, @Component or the JSR 330 @Named annotation or define the beans in xml with autowiring attributes or last but not least define the beans in a Java configuration. To wire up the injection targets you can use the @Autowired or the JSR 330 @Inject annotation or wire up the target in the XML bean definition.

Well the sense of this post isn’t to explain Spring dependency injection in deep. I will rather discuss what happens if Spring found multiple beans qualified for injection, and how you can help Spring to make the decision which is the right one bean. I use the JSR 330 annotations, The examples also works with the Spring annotations @Service and @Autowire.

Read More...

Spring – load multiple property based on utils properties code

With the utils namespace in Spring 3.0 you can load a property file and use the values in Spring EL expressions. Unlike the valued flexibilty of other Spring components, utils:properties lacks possibilty to add multiple property file locations. But there is no problem to support multiple property locations by usage of PropertiesFactoryBean, the source of util:properties

Read More...