1.首先从springframework的官网上下载所需要的jar包
官网:http://spring.io/
2.spring所需要的jar包
Spring-core-3.2.x.RELEASE.jar | spring框架核心jar包 |
Spring-beans-3.2.x.RELEASE.jar | spring框架管理Bean工厂的jar包 |
Spring-context-3.2.x.RELEASE.jar | spring框架上下文环境依赖的jar包 |
Spring-expression-3.2.x.RELEASE.jar | Spring表达式语言依赖的jar包 |
Commons-logging-1.x.x.jar | spring依赖的第三方的jar包 |
在eclipse中建立一个java project,引入以上所需要的jar包,选中所建的工程右击鼠标选择BuildPath -> Add Libraries ->User Libraries里面选择所存jar包的名称后点击
finish完成对jar薄的引入
4.在xml文件中的配置
java工程:
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 使用这种调用方法是调用当前class所指向类中方法 -->
<bean id="dao" class="com.phome.dao.DAO">
<property name="name" value="mysql"></property>
</bean>
<bean id="service" class="com.phome.service.Service">
<property name="dao" ref="dao"></property>
</bean>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 使用这种调用方法是调用当前class所指向类中方法 -->
<bean id="dao" class="com.phome.dao.DAO">
<property name="name" value="mysql"></property>
</bean>
<bean id="service" class="com.phome.service.Service">
<property name="dao" ref="dao"></property>
</bean>
</beans>
以上就是大体的spring框架配置