spring基本环境搭建,以及需要用到的一些包
来源:互联网 发布:工程优化设计收费标准 编辑:程序博客网 时间:2024/06/05 15:49
这里写代码片必须要的包:
spring-context-版本.RELEASE.jar (此包用于检测配置文件applicationcontext.xml)
spring-beans-版本.RELEASE.jar (此包用于读取applicationcontext.xml里面的bean)
spring-expression-版本.RELEASE.jar (此包为错误输出,没有的时候无法启动程序)
commons-logging-版本.RELEASE.jar (此包为日志输出包,没有会报错,无法启动)
第一步,先建立目录
第二步,配置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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd "> <bean id="southMan" class="com.bean.SouthMan"></bean> <bean id="northMan" class="com.bean.NorthMan"></bean></beans>
这里面的一些引用,目前还没完全清楚,有待琢磨。
第三步,编写方法对应类的方法
1、定义Peson接口
package com.inter;public interface Person { public void eit(); public void drink();}
2、写实现类
package com.bean;import com.inter.Person;public class NorthMan implements Person{ @Override public void eit() { System.out.println("北方人吃面!"); } @Override public void drink() { System.out.println("喜欢喝水。"); }}
3、写测试类test
package com.test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.FileSystemXmlApplicationContext;import com.bean.NorthMan;import com.bean.SouthMan;public class Test { public static void main(String[] args) { ApplicationContext ap = new FileSystemXmlApplicationContext("src/applicationContext.xml"); NorthMan n = (NorthMan) ap.getBean("northMan"); n.eit(); n.drink(); }}
0 0
- spring基本环境搭建,以及需要用到的一些包
- mybatis+spring整合需要用到的包
- Spring基础环境搭建所需要的jar包
- Spring mvc 环境搭建以及基本应用
- spring需要的一些jar包
- struts2.3.16环境搭建要用到的jar包
- [精华]struts2+spring+hibernate手动搭建环境需要的jar包
- Spring开发环境搭建以及相关jar包介绍
- Spring的基本环境的搭建
- 搭建ssh2(struts2.1.8,spring2.5.6,hibernate3)需要用到的所有jar包的名字
- S2SH所需要用到的包
- SSM整合需要用到的包
- 使用arcgis for Android 在eclipse开发环境下需要用到的jar包
- sharepoint 2010 moss 培训教程 sharepoint开发经常需要用到的一些基本知识点
- Spring中使用aop操作需要用到的aspectjweaver-1.8.7.jar包
- 经常需要用到的基本文档
- spring搭建所需要的jar包汇总详解
- Idea 搭建spring web应用程序 需要的jar包
- matlab——meanshift
- 毕业论文中引言与摘要的区别
- Java反射
- DES加密如何保持一致
- uml可以快速看出不好的程序结构
- spring基本环境搭建,以及需要用到的一些包
- extjs 使用Ext.Ajax.request进行数据传输
- Android中内容观察者的使用---- ContentObserver类详解
- php程序员阶段
- C#基础知识之结构体(Struct)
- 对页面数据进行按某一字段排序显示
- android 内存泄露笔记
- eclipse代码注释之模板xml
- postgresql数据库对象管理之非模式对象