使用Annotation配置spring4 开启自动扫描组件
package com.michael;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* Created by huangbin on 2016/1/31.
*/
@Configuration
@ComponentScan
public class Application {
public static void main(String args[]) {
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(HelloWorld.class);
HelloWorld helloWorld = applicationContext.getBean(HelloWorld.class);
System.out.println(helloWorld.toString());
}
}