- @Controller 控制器组件
- @Service 业务层组件
- @Component 通用组件
@Controller("abc")
public class DemoController implements Serializable {
@Override
public String toString() {
return "DemoController";
}
}
@Service
public class DemoService implements Serializable {
@Override
public String toString() {
return "DemoService";
}
}
@Test
public void testDemoController(){
DemoController controller = ctx.getBean(
"abc",DemoController.class
);
System.out.println(controller);
}
@Test
public void testDemoService(){
DemoService service = ctx.getBean("" +
"demoService",DemoService.class);
System.out.println(service);
}