2.1 各种标签
来源:互联网 发布:剑三军爷男神捏脸数据 编辑:程序博客网 时间:2024/05/29 09:12
1. 关于各种注解:Spring注解@Component、@Repository、@Service、@Controller区别
自己的话:原来只有@Componenti一种注解,后来添加了其他三种,效果是一样的。都是xml文件里配置解析器去读配有这几个注解的类
,但是用不同的文意标示更能体现中三层架构的含义。
http://blog.csdn.net/zhang854429783/article/details/6785574
在目前的 Spring 版本中,这 3 个注释和 @Component 是等效的,但是从注释类的命名上,很容易看出这 3 个注释分别和持久层、业务层和控制层(Web 层)相对应。
虽然目前这3 个注释和 @Component 相比没有什么新意,但 Spring 将在以后的版本中为它们添加特殊的功能。
所以,如果 Web 应用程序采用了经典的三层分层结构的话,最好在持久层、业务层和控制层分别采用上述注解对分层中的类进行注释。
@Service用于标注业务层组件
@Controller用于标注控制层组件(如struts中的action)
@Repository用于标注数据访问组件,即DAO组件
@Component泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注。
<?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:annotation-config /> <context:component-scan base-package=”com.eric.spring”> </beans>
<tx:annotation-driven transaction-manager="txManager"/>
负责解析注解: @service @transaction等
2.
Buyer 实体类上的 @Entity,@Id, @Column
@Entitypublic class Buyer {private String username;private String password;//MD5private String email;@Id @Column(length=20)public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}@Column(length=32, nullable=false)public String getPassword() {return password;}
0 0
- 2.1 各种标签
- 各种标签
- JSP各种标签
- javaweb 各种include标签
- 各种标签引用
- HTML各种标签总结
- 各种标签表达式集合
- html中各种标签
- 各种标签去除
- html标签之视频各种标签
- XHTML各种标签的运用
- html中的各种标签组件
- WordPress各种标签调用集合
- JSP中的各种标签表达式
- PHP过滤各种HTML标签
- 前端meta标签各种使用
- PHP过滤各种HTML标签
- html标签各种属性的含义
- IOS 如何选择delegate、notification、KVO?
- 模板方法和接口参数的联合使用
- [CF538F]A Heap of Heaps && 持久化线段树
- 第四章第5题
- 第4章 第7题
- 2.1 各种标签
- CACTI :Required modules for PHP Weathermap 0.97c were not present. Not running
- 编程之美2.17—数组循环移位(旋转数组)
- Linux串口驱动分析初始化
- getBaseContext(),getApplication(),getApplicationContext()
- 市赛回顾
- linux实现shell命令支持ipv4地址转换
- 进程与线程的一个简单解释
- HDU 1062 — Text Reverse