【1.0】spring4环境搭建

1.导包,略。

2.在src路径下创建applicationContext.xml文件,模板如下:

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:cache="http://www.springframework.org/schema/cache" xmlns:p="http://www.springframework.org/schema/p"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
     http://www.springframework.org/schema/aop
     http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-4.0.xsd
     http://www.springframework.org/schema/tx
     http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
     http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-4.0.xsd">
     
     <!-- action配置  -->
     <bean id="testIocAction" class="action.TestIocAction">
    	<!--constructor-arg代表是通过构造函数注入,ref的值表示注入的内容-->  
    	<constructor-arg  ref="testIocService"/> 
     </bean>
     
     <!-- service配置 -->
     <bean id="testIocService" class="service.TestIocService">
    	<!--constructor-arg代表是通过构造函数注入,ref的值表示注入的内容-->  
    	<constructor-arg  ref="testIocDao"/>    
     </bean>
     
     <!-- dao配置 -->
     <bean id="testIocDao" class="dao.TestIocDao"></bean>
     
</beans>

  

posted @ 2017-04-15 14:41  chxbar  阅读(159)  评论(0编辑  收藏  举报