Spring(二)、注解IOC
一、Spring 的 IOC 的注解开发
1.1、Spring 的 IOC 的注解开发入门
Hibernate 和 Struts 框架也有注解开发,但在实际开发过程中应用不是很多。
1.1.1、创建 Web 项目,引入 jar 包
在 Spring3.X 的版本中,IOC 的注解开发做需要的 jar 包,和 XML 开发所引的包是一样的。
在 Spring4 的版本中,除了引入基本的开发包以外,还需引入 AOP 的包。
1.1.2、引入 Spring 的配置文件
在 src 下创建 applcationContext.xml
引入约束:使用注解开发引入 context 约束
约束:D:\Spring\spring-framework-4.2.4.RELEASE\docs\spring-framework-reference\html\xsd-configuration.html
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 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"> <!-- bean definitions here --> </beans>
1.1.3
二、Spring 的 A.OP 的 XML 开发