【工程截图】

【PersonDao.java】

package com.HigginCui.annotation;

public interface PersonDao {
public void savePerson();
}

【PersonDaoImpl.java】

package com.HigginCui.annotation;

import org.springframework.stereotype.Repository;
/*
* @Repository("personDao")相当于
* <bean id="personDao" class="......PersonDaoImpl"></bean>
*/
@Repository("personDao")
public class PersonDaoImpl implements PersonDao{
public void savePerson() {
System.out.println("save Person...");
}
}

【PersonService.java】

package com.HigginCui.annotation;

public interface PersonService {
public void savePerson();
}

【PersonServiceImpl.java】

package com.HigginCui.annotation;

import javax.annotation.Resource;
import org.springframework.stereotype.Service; @Service("personService")
public class PersonServiceImpl implements PersonService{
@Resource(name="personDao")
private PersonDao personDao;
public void setPersonDao(PersonDao personDao) {
this.personDao = personDao;
}
@Override
public void savePerson() {
this.personDao.savePerson();
}
}

【PersonAction.java】

package com.HigginCui.annotation;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller; @Controller("personAction")
public class PersonAction {
@Resource(name="personService")
private PersonService personService; public void setPersonService(PersonService personService) {
this.personService = personService;
} public void savePerson(){
this.personService.savePerson();
}
}

【applicationContext.xml】

<?xml version= "1.0" encoding ="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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"> <!-- 把一个类放入到Spring容器中,该类就是一个component,此时不需要声明对应的bean -->
<context:component-scan base-package="com.HigginCui.annotation"></context:component-scan>
</beans>

【testPerson.java】

save Person...

12_注解04_注解实现Action调用Service,Service调用Dao的过程的更多相关文章

  1. Myeclipse插件快速生成ssh项目并配置注解 在action层注入service的超详细过程

    最近发现,我对于ssh的 自动注入配置 还是不熟悉,于是整理了一下 终于做了一个 简单的 注入配置出来. 以前都是在applicationContext.xml 里面这样配 <bean id=& ...

  2. spring注解@service("service")括号中的service有什么用

    相当于 xml配置中得 bean id = service 也可以不指定 不指定相当于 bean id = com. service.service 就是这个类的全限定名 好处是:同一个接口可以有多个 ...

  3. Spring中@Component注解,@Controller注解详解

    在使用Spring的过程中,为了避免大量使用Bean注入的Xml配置文件,我们会采用Spring提供的自动扫描注入的方式,只需要添加几行自动注入的的配置,便可以完成 Service层,Controll ...

  4. JavaEE开发之Spring中的条件注解组合注解与元注解

    上篇博客我们详细的聊了<JavaEE开发之Spring中的多线程编程以及任务定时器详解>,本篇博客我们就来聊聊条件注解@Conditional以及组合条件.条件注解说简单点就是根据特定的条 ...

  5. Spring普通类/工具类获取并调用Spring service对象的方法

    参考<Spring普通类获取并调用Spring service方法>,网址:https://blog.csdn.net/jiayi_0803/article/details/6892455 ...

  6. Spring_day02--课程安排_Spring的bean管理(注解)(注解创建对象/注入属性、配置文件和注解混合使用)

    Spring_day02 上节内容回顾 今天内容介绍 Spring的bean管理(注解) 注解介绍 Spring注解开发准备 注解创建对象 注解注入属性 配置文件和注解混合使用 AOP概念 AOP原理 ...

  7. spring常用的一些注解以及注解注入总结

    常用的spring注解有如下几种: @Controller@Service@Autowired@RequestMapping@RequestParam@ModelAttribute@Cacheable ...

  8. Spring的注解@Qualifier注解

    @Qualifier注解了,qualifier的意思是合格者,通过这个标示,表明了哪个实现类才是我们所需要的,我们修改调用代码,添加@Qualifier注解,需要注意的是@Qualifier的参数名称 ...

  9. java中Action层、Service层和Dao层的功能区分

    Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DAO只 ...

随机推荐

  1. 微软Azure运营方世纪互联遭做空后强劲反弹

    http://www.cnblogs.com/sennly/p/4135594.html 最近几天微软Azure的运营方世纪互联被Trinity做空,股价震荡巨大,先让我们回顾下整个事件: 9月11日 ...

  2. PLSQL配置介绍

    PLSQL配置简介,优化   来自为知笔记(Wiz) 附件列表 s=selectf=FROMw=WHEREsf=SELECT * FROMdf=DELETE FROMsc=SELECT COUNT(* ...

  3. HW3.3

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. pm 2.5

    定陵</a></div><div class="staaqi"><span class="label pmsmall" ...

  5. hdoj 5522 Numbers

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5522 水题:暴力过 #include<stdio.h> #include<strin ...

  6. 检查REDO日志相关信息并生成HTML文件的脚本

    生成HTML格式的文件 内容有: 检查数据库版本.REDO日志组情况, 最近20次日志切换频率检查--日志间的归档时间间隔, 这对查看数据库的IO繁忙时段 统计指定日期当天每小时的归档日志产生量--日 ...

  7. PAT 1089. Insert or Merge (25)

    According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and gr ...

  8. 【腾讯优测干货分享】如何降低App的待机内存(五)——优化dex相关内存及本章总结

    本文来自于腾讯优测公众号(wxutest),未经作者同意,请勿转载,原文地址:http://mp.weixin.qq.com/s/01Abwe0p1h3WLh28Tzg_Dw 1.5案例:优化dex相 ...

  9. iOS开发中打开本地应用、打开appStore应用、给app评分功能实现

    app开发中,通常会有邀请用户给app打分的功能.而在iOS中,正式应用都是通过appStore 下载的,因此给app 打分也只能在 appStore中.因此,需要从应用跳转到appStore.方法是 ...

  10. 如何通过进程名获取进程ID

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:如何通过进程名获取进程ID.