一,项目结构图

二,applicationContext.xml

<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="personDao" class="com.deppon.test04.dao.impl.PersonDao"></bean> <bean id="personService" class="com.deppon.test04.service.impl.PersonService">
<property name="personDao" ref="personDao"></property>
</bean> </beans>

三,service

package com.deppon.test04.service;

public interface IPersonService {

    public void processSave();
}
package com.deppon.test04.service.impl;

import com.deppon.test04.dao.IPersonDao;
import com.deppon.test04.service.IPersonService; public class PersonService implements IPersonService {
private IPersonDao personDao; public void setPersonDao(IPersonDao personDao) {
this.personDao = personDao;
} public void processSave() {
System.out.println("-------------from PersonService.processSave()"); personDao.save();
} }

四,dao

package com.deppon.test04.dao;
public interface IPersonDao { public void save(); }
package com.deppon.test04.dao.impl;

import com.deppon.test04.dao.IPersonDao;

public class PersonDao implements IPersonDao {

    public void save() {
System.out.println("------------from PersonDao.save()");
} }

五,测试类

package com.deppon.test04.service;

import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext; public class PersonServiceTest {
private BeanFactory factory = null; @Before
public void before() {
factory = new ClassPathXmlApplicationContext("applicationContext.xml");
} @Test
public void testSpring() {
IPersonService personService = (IPersonService) factory.getBean("personService");
personService.processSave();
}
}

转自https://blog.csdn.net/yuguiyang1990/article/details/8799307

maven+Spring环境搭建的更多相关文章

  1. Spring环境搭建之:导入jar包、配置文件名称及放置位置

    Spring环境搭建之:导入jar包.配置文件名称及放置位置 现在项目开发中spring框架应用的还是比较多的,自己用的还不太熟练,每次用的时候总配置半天,总有些配置弄错,就找个时间总结以下,方便以后 ...

  2. 【Spring学习笔记-1】Myeclipse下Spring环境搭建

    *.hl_mark_KMSmartTagPinkImg{background-color:#ffaaff;}*.hl_mark_KMSmartTagBlueImg{background-color:# ...

  3. 【搬运工】之——Selenium+IDEA+Maven+TestNG环境搭建(转)

    Selenium+IDEA+Maven+TestNG环境搭建 第一 安装java环境. 1. 下载并安装Jdk1.7或Jdk1.8 http://www.oracle.com/technetwork/ ...

  4. 【Spring环境搭建】在Myeclipse下搭建Spring环境-web开发

    <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" ...

  5. Spring之Spring环境搭建

    Spring之Spring环境搭建 一.什么是Spring? Spring框架是由于软件开发的复杂性而创建的.Spring使用的是基本的JavaBean来完成以前只可能由EJB完成的事情.然而,Spr ...

  6. TestNG+Maven+IDEA环境搭建

    TestNG+Maven+IDEA环境搭建 前言: 主要进行TestNG测试环境的搭建 所需环境: 1.IDEA UItimate 2.JDK 3.Maven 一.创建工程 File –>new ...

  7. SSH环境搭建之Spring环境搭建篇

    SSH环境搭建之Spring环境搭建篇 一.引入Spring所使用的JAR文件 二.在src目录下创建beans.xml(Spring的容器文件) <?xml version="1.0 ...

  8. SSM Spring+SpringMVC+mybatis+maven+mysql环境搭建

    SSM Spring+SpringMVC+mybatis+maven环境搭建 1.首先右键点击项目区空白处,选择new->other..在弹出框中输入maven,选择Maven Project. ...

  9. spring+springMVC+mybatis+maven+mysql环境搭建(一)

    环境搭建是最基础的,但是发现平时很多时候大家都是ctrl c+ctrl v,这样对于很多细节完全不清楚,来,一起深入了解下 一.准备工作 首先得准备好maven.mysql啥的,这些略... 并且my ...

随机推荐

  1. usb被占用时,可以用这些方法进行adb无线调试

    转自: http://www.cnblogs.com/shangdawei/p/4480278.html 可用wifi.网口. 1.先要获取root权限 如果手机没有命令行工具,请先在手机端安装终端模 ...

  2. h5-26-web本地存储

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. string类常用方法3

  4. SQL 列拼接使用

    一个产品收藏表 Collection , 把该产品被收藏的人拼接在一列中如下: SQL SERVER SELECT ProjectID, UserIDs = ','+(STUFF((SELECT ', ...

  5. [转]Android 如何监听返回键,弹出一个退出对话框

    本文转自:http://blog.csdn.net/sunnyfans/article/details/8094349 Android 如何监听返回键点击事件,并创建一个退出对话框, 防止自己写的应用 ...

  6. [转]C#综合揭秘——细说多线程(下)

    引言 本文主要从线程的基础用法,CLR线程池当中工作者线程与I/O线程的开发,并行操作PLINQ等多个方面介绍多线程的开发. 其中委托的BeginInvoke方法以及回调函数最为常用. 而 I/O线程 ...

  7. [转].NET MVC 分页以及增删查改

    本文转自:http://blog.csdn.net/sust2012/article/details/30761867 . 数据库操作,DAL 层: using System; using Syste ...

  8. Linux OpenGL 实践篇-11-shadow

    OpenGL 阴影 在三维场景中,为了使场景看起来更加的真实,通常需要为其添加阴影,OpenGL可以使用很多种技术实现阴影,其中有一种非常经典的实现是使用一种叫阴影贴图的实现,在本节中我们将使用阴影贴 ...

  9. scriptPubKey and scriptSig

    First of all two matching scripts are used in two different transactions, one that transfers funds t ...

  10. Python3简明教程(四)—— 流程控制之分支

    我们通过 if-else 语句来做决定,来改变程序运行的流程. if语句 语法如下: if expression: do this 如果表达式 expression 的值为真(不为零的任何值都为真), ...