@Component @Service @Controller @Repository注解使用
来源:互联网 发布:java 泛型方法 调用 编辑:程序博客网 时间:2024/06/05 18:45
@Component 相当于实例化类的对象。
通过在 classpath 中通过自动扫描方式把组建纳入 spring 容器管理。
要使用自动扫描机制我们需要打开一下配置信息:
- <?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-2.5 .xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-2.5 .xsd">
- <context:component-scan base-package="com.zchen" />
- </beans>
注:前面讲要使用注解需要配置: <context:annotation-config />但如果使用了@Component就不需要加它了,因为:<context:component-scan base-package="com.zchen">里面默认了<context:annotation-config />。
- @Component ( "userService" )
- public class UserService {
@Service用于标注业务层组件、
@Controller用于标注空竹曾组件(如Struts中的action)
@Repository用于标注数据访问组件即DAO组件
@Component泛指组件,当组件不好归类的时候我们可以使用这个注解进行标注,(现在可以都用此注解)
0 0
- @Component @Service @Controller @Repository注解使用
- 使用component,repository,Service,controller注解
- @Component @Service @Controller @Repository注解使用
- Spring注解@Component、@Repository、@Service、@Controller使用
- 注解@Component @Controller @Service @Repository
- 注解@Component,@Controller,@Service,@Repository
- @Component,@Service,@Controller,@Repository注解
- Spring注解的使用和区别:@Component、@Service、@Repository、@Controller
- Spring注解的使用和区别:@Component、@Service、@Repository、@Controller
- @Component @Service @Controller @Repository注解使用
- Spring注解使用以及@Component、@Repository、@Service、@Controller区别
- spring注解-@Component(不推荐使用)、@Repository、@Service、@Controller
- Spring注解@Component、@Repository、@Service、@Controller区别
- Spring注解@Component、@Repository、@Service、@Controller区别
- Spring 注解@Component,@Service,@Controller,@Repository
- Spring 注解@Component,@Service,@Controller,@Repository
- Spring注解@Component、@Repository、@Service、@Controller区别
- Spring注解@Component、@Repository、@Service、@Controller区别
- POJ 1001 Exponentiation解题报告
- Oracle 客户端配置后,同时再装服务器端出现的无法同时链接远程服务器和本地的问题
- java设计模式-代理模式
- MFC窗口中的SetOnwer等。
- C++ 类的多重继承
- @Component @Service @Controller @Repository注解使用
- ZXR10 1800路由器配置
- 搭建Samba服务
- JNI本地文件添加打印输出到LOGCAT
- 通过JS检查上传附件大小以及文件类型
- windows服务代码编写完后的安装步骤
- java读写文本文件
- mysql数据库导入sql server
- android AsyncTask介绍