<context:annotation-config>
1 autowired
@Autowired(required=false) //允许null
@Qualifier("name1")
@Strummed
private Object value;
<bean class=""><qualifier value="name1"/></bean>
2 inject
@Inject //不允许null
@Named("name1")//标记id
private Object value2;
3 value表达式
@Value("#{systemProperties.myFavoriteSong}")
private String song; //spel表达式
-------------------------------------------------------------------------------
自动注册bean
<context:component-scan base-package="" />
@component
@Controller
@RequestMapping
<context:component-scan base-package="" ><context:include-filter type="assignable" expression=""/></context:component-scan>
<context:component-scan base-package="" ><context:exclude-filter type="annotation" expression=""/></context:component-scan>
@Configuration
public class Stage {
@Bean
private Performer duke(){
return new Juggler(15);
}
@Bean
private Juggler duke2(){
return new PoeticJuggler(duke());
}
}