核心思想:IOC控制反转,AOP面向切面
一、首先去官网下载开发包以及文档
这里学习的是4.0.6,我们暂时不需要全部Spring功能,导入核心包即可
二、创建一个Java项目,把核心包放到项目下面然后Build Path
这样框架就差不多搭建好了
三、Spring用beans.xml管理实例
创建beans.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">
</beans>
写一个简单helloworld实例
然后由beans.xml管理实例
就是说我们可以通过helloworld来使用com.java.test.HelloWorld实例
<?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">
<bean id="helloworld" class="com.java.test.HelloWorld"> </bean>
</beans>
然后使用beans