Spring Framework Annotation- Part 3

Using Spring's Java-based configuration.

Even though Spring’s Java configuration option enables you to write most of your
Spring configuration without XML, you’ll still need a minimal amount of XML to boot-
strap the Java configuration:


<?xml version="1.0"encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan
base-package="com.xxx.bar"/>
</beans>



@Configuration: Serves as a clue to Spring that this class will contain one or more Spring bean declarations. Those bean


@Configuration
public classSpringIdolConfig{

@Bean
public Performerduke(){
return newJuggler();
}

}

@Bean tells Spring that this method will return an object that should be registered as a bean in the Spring application context. The bean will get its ID from the method name.

Comments

Popular posts from this blog

Stretch a row if data overflows in jasper reports

JasperReports - Configuration Reference

Spring - Operations with jdbcTemplate