首页 > 代码库 > spring

spring

ioc 和aop是spring的核心

spring整合其他技术,例如jdbc,mybtis,hibernate,struts等。

 

spring ioc应用

a。管理对象

  创建,初始化,释放资源,销毁

b。维护对象关系

c。搭建SpringIOC开发环境,引入jar包,在src添加applicationContext.xml

spring模块需要的jar包:

ioc:commons-logging,spring-beans,spring-context,spring-core,spring-expression

aop:

dao:

dbcp:

json:

webmvc:

 


例子:

java代码:

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco } span.s1 { text-decoration: underline; color: #7e504f } span.s2 { color: #931a68 } span.s3 { color: #3933ff } span.s4 { color: #7e504f } span.s5 { color: #0326cc } span.Apple-tab-span { white-space: pre }</style>

ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");

Calendar c1=ac.getBean("c1",Calendar.class);

System.out.println(c1);

applicationContext.xml:

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #3933ff } span.s1 { color: #009193 } span.s2 { color: #4e9192 } span.s3 { color: #000000 } span.s4 { color: #932192 }</style>

<bean id="c1" class="java.util.GregorianCalendar"></bean>

 

spring