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 ...
随机推荐
- Query on a tree again! SPOJ - QTREE3
https://vjudge.net/problem/SPOJ-QTREE3 https://www.luogu.org/problemnew/show/P4116 一个log(LCT)比两个log( ...
- Mice and Holes CodeForces - 797F
Mice and Holes CodeForces - 797F 题意:有n只老鼠和m个洞,都在一个数轴上,老鼠坐标为x[1],...,x[n],洞的坐标为p[1],...,p[m],每个洞能容纳的老 ...
- 1. Visio Web 形状 - 无法与 Web 服务器建立连接。请稍后重新进行搜索。处理方式
今天在Visio中使用“搜索形状”,发现不管搜什么,结果都是:Visio Web 形状 - 无法与 Web 服务器建立连接.请稍后重新进行搜索 具体解决方案如下:控制面板=>添加或删除程序=&g ...
- Spark网络通信分析
之前分析过spark RPC的基本流程(spark RPC详解),其实无论是RPC还是Spark内部的数据(Block)传输,都依赖更底层的网络通信,本文将对spark的网络通信做一下剖析. 1,概要 ...
- PHP 讓 json_encode() 指定回傳格式
PHP 回傳 JSON 很方便, 只要將資料經過 json_encode() 就解決了. 不過因為 PHP 自動轉換型別, 造成很多資料都習慣存成字串, 希望在輸出 JSON 的時候, 數字部份可以輸 ...
- lock和synchronized的同步区别与选择
1. lock是一个接口,而synchronized是java的一个关键字,synchronized是内置的语言实现:(具体实现上的区别在<Java虚拟机>中有讲解底层的CAS不同,以前有 ...
- xutils3批量上传文件
前几天开发安卓要用到文件批量上传,就是上传图片,视频,文件之类的用到Xutil3框架,用 RequestParams params = new RequestParams(url); params.a ...
- IOS访问webserver接口
接口调用参数只能是字符串格式,返回格式支持3种(字符串,数组,DataSet) 需要引用第三方库,包含(DataSet,PlatServinceDataParser,WebserviceCommon, ...
- android开发工具eclipse的安装与配置
l开发主要应用Eclipse 3.7版本. l辅助工具为jdk.Androidsdk Android环境搭建 –1.1.JDK安装 –1.2.Eclipse安装 –1.3.Android SDK安 ...
- 微信小程序开发系列五:微信小程序中如何响应用户输入事件
微信小程序开发系列教程 微信小程序开发系列一:微信小程序的申请和开发环境的搭建 微信小程序开发系列二:微信小程序的视图设计 微信小程序开发系列三:微信小程序的调试方法 微信小程序开发系列四:微信小程序 ...