SSH或SHSpringMVC下采用spring的Annotation配置dao,service,controller(便于团队开发,各自修改自己的annotation)
来源:互联网 发布:勒索病毒怎么恢复数据 编辑:程序博客网 时间:2024/06/01 10:09
使用此功能的前提必须是Spring3.0或以上版本。
在和数据库连接的spring配置文件中修改,此文的项目基础来源于http://blog.csdn.net/needkane/article/details/21410805
我们在applicationContext-hibernate.xml修改
从头一行开始
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd">加入下面的配置,设置允许使用Annotation,并设置Annotation作用的包范围,其中要包括dao.impl,service.impl和action。
<context:annotation-config></context:annotation-config>
<context:component-scan
base-package="com.kane.action,com.kane.back.service.impl,com.kane.dao.impl">
</context:component-scan>
接下来数据源等配置和以前一样,这样代替了xml配置
dao.impl类的声明
// 表示该类自动配置成为一个Spring的<bean>,id为类名首字母小写
@Component
service类的声明@Service
action类的声明
// 也表示是一个<bean>
@Controller
// 不使用单例设计
@Scope(value = "prototype")
- SSH或SHSpringMVC下采用spring的Annotation配置dao,service,controller(便于团队开发,各自修改自己的annotation)
- Spring的Annotation配置
- Spring的Annotation配置
- Spring---->采用Annotation的方式实现AOP
- spring对AOP的支持(采用Annotation的方式)
- spring对AOP的支持(采用Annotation方式)
- spring-基于注释(Annotation)的配置
- spring-基于注释(Annotation)的配置
- Spring的零配置(Annotation)
- SSH采用annotation注入
- Spring2.5中annotation配置中@Override、@Component、 @Controller、 @Service、 @Repository、@Autowired的解析
- 采用annotation的方式配置Spring的IOC和AOP/采用XML的方式配置Spring的IOC和AOP
- SSH框架联合开发(Annotation精简Spring的配置文件)
- SSH框架联合开发(Annotation精简Spring的配置文件)
- Spring Annotation(注解)的使用步骤(SSH)
- dwr整合ssh 的annotation配置方式
- Spring Annotation Controller
- 设计自己的Annotation
- speex 笔记(二)
- Windows下多线程编程指南
- 杭电1702 ACboy needs your help again!
- CSS position 属性
- HDU 2000 - 2009
- SSH或SHSpringMVC下采用spring的Annotation配置dao,service,controller(便于团队开发,各自修改自己的annotation)
- 线程阻塞的原因
- 理解int 和integer的用法
- Introduction to FEM based CFD algorithms ( 基于有限元的CFD算法)
- struts2.1.8+hibernate2.5.6+spring3.0(ssh2三大框架)常见异常原因和解决方案(上)
- Java常见异常(Runtime Exception )小结&&关于RuntimeException异常
- CR块
- 现在EJB3实体Bean是纯粹的POJO.
- id的配置