maven+Spring环境搭建
一,项目结构图

二,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环境搭建的更多相关文章
- Spring环境搭建之:导入jar包、配置文件名称及放置位置
Spring环境搭建之:导入jar包.配置文件名称及放置位置 现在项目开发中spring框架应用的还是比较多的,自己用的还不太熟练,每次用的时候总配置半天,总有些配置弄错,就找个时间总结以下,方便以后 ...
- 【Spring学习笔记-1】Myeclipse下Spring环境搭建
*.hl_mark_KMSmartTagPinkImg{background-color:#ffaaff;}*.hl_mark_KMSmartTagBlueImg{background-color:# ...
- 【搬运工】之——Selenium+IDEA+Maven+TestNG环境搭建(转)
Selenium+IDEA+Maven+TestNG环境搭建 第一 安装java环境. 1. 下载并安装Jdk1.7或Jdk1.8 http://www.oracle.com/technetwork/ ...
- 【Spring环境搭建】在Myeclipse下搭建Spring环境-web开发
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" ...
- Spring之Spring环境搭建
Spring之Spring环境搭建 一.什么是Spring? Spring框架是由于软件开发的复杂性而创建的.Spring使用的是基本的JavaBean来完成以前只可能由EJB完成的事情.然而,Spr ...
- TestNG+Maven+IDEA环境搭建
TestNG+Maven+IDEA环境搭建 前言: 主要进行TestNG测试环境的搭建 所需环境: 1.IDEA UItimate 2.JDK 3.Maven 一.创建工程 File –>new ...
- SSH环境搭建之Spring环境搭建篇
SSH环境搭建之Spring环境搭建篇 一.引入Spring所使用的JAR文件 二.在src目录下创建beans.xml(Spring的容器文件) <?xml version="1.0 ...
- SSM Spring+SpringMVC+mybatis+maven+mysql环境搭建
SSM Spring+SpringMVC+mybatis+maven环境搭建 1.首先右键点击项目区空白处,选择new->other..在弹出框中输入maven,选择Maven Project. ...
- spring+springMVC+mybatis+maven+mysql环境搭建(一)
环境搭建是最基础的,但是发现平时很多时候大家都是ctrl c+ctrl v,这样对于很多细节完全不清楚,来,一起深入了解下 一.准备工作 首先得准备好maven.mysql啥的,这些略... 并且my ...
随机推荐
- npm install error: MSBUILD : error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”
When I tried to run angular 4 material2 demo on my windows server 2012, got a error message: node-pr ...
- springMVC的架构与执行流程
SpringMVC术语 前端控制器(DispatcherServlet):接收请求,响应结果,相当于电脑的CPU. 处理器映射器(HandlerMapping):根据URL去查找处理器 处理器(Han ...
- [转]MVC 检测用户是否已经登录
本文转自:http://blog.csdn.net/jayzai/article/details/41252137 当我们访问某个网站的时候需要检测用户是否已经登录(通过Session是否为null) ...
- AndroidStudio中使用SVN
AndroidStudio中使用SVN提交项目 1.安装SVN,我选择使用TortoiseSVN-1.8.7.25475-x64-svn-1.8.9.msi(安装文件地址如下:http://downl ...
- expect下命令不能解析通配符*的问题
曾遇到这样一段代码:(Bash脚本) 1 2 3 4 5 6 7 8 9 10 11 12 #!/usr/bin/expect -f set HOST "192.168.102.1" ...
- android studio 定时器操作 实现定时执行相关任务
package ipget.wenzheng.studio.ipget; import android.os.Bundle; import android.os.Handler; import and ...
- CCF|火车购票|Java|80分
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Sc ...
- iframe 完全跨域自适应高度
1.跨域访问页面, 需要访问后台的页面,通过后台调转 2.跨域自适应宽高 思路:通过相互嵌套,获取跨域页面的高度,通过src传回到本域,通过parent方法设置主页的iframe的高度 index ...
- Android学习笔记(十九) OkHttp
一.概述 根据我的理解,OkHttp是为了方便访问网络或者获取服务器的资源,而封装出来的一个工具包.通常的使用步骤是:首先初始化一个OkHttpClient对象,然后使用builder模式构造一个Re ...
- [译] 用win7自带工具找出svchost.exe的CPU使用率达到100%的元凶
本文是我对自己上一篇转载的博客 <Figuring out why my SVCHOST.EXE is at 100% CPU without complicated tools in Wind ...