The base Module

The base module is responsible only for letting you configure eny bean in the spring context almost without using any XML. You can use it as easy as instantiating the ApplicationContext for your application programaticaly.

Just add the Spring-Annotation Schema to your spring XML file:

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:sa="http://sannotations.sourceforge.net/context"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://sannotations.sourceforge.net/context http://sannotations.sourceforge.net/context.xsd">



and use the following code:

<import resource="classpath*:applicationContext.xml"/>

<sa:annotation-autoload />

After this you can use it as any other Spring Framework application context. To register beans you can use the standard way (writing one or more applicationContext.xml files) or using the Spring-Annotation annotations as follow.

  • @Bean

    Using this annotation you can setup any bean in the application context, it has the same properties as the <bean> tag
  • @Property

    This annotation enables you to configure the properties of a bean when you do not want to use the autowire by name (the default behavior)
  • @ConstructorArgs

    This annotation enables you to configure the parameters for a constructor of a bean when you do not want to use the autowire by name (the default behavior)

Example

If you look at the Example 1 project there is an example of using only the base module.