Hello World
1.2.1 Maven的使用
1)maven的javase工程目录
file->new->maven project
2)maven的settings.xml的配置:更改镜像,指定仓库地址,指定代理服务器
1.2.2第一个程序
1)所需基础jar包:core context beans commons-logging
用pom.xml在maven仓库中下载
2)applicationContext.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
</beans>
3)定义java类
定义一个接口
定义该接口实现类
4)将类在配置文件applicationContext.xml中配置成bean
<bean id="" class=""></bean>
5)编写测试类:实例化容器,从容器中获取对象,执行其方法