首页 / 软件开发 / JAVA / spring入门(2)--写在第一个案例前
spring入门(2)--写在第一个案例前2013-07-18 csdn 史国旭1、引入spring的jar文件libs/spring-beans-3.2.2.RELEASE.jarlibs/spring-context-3.2.2.RELEASE.jarlibs/spring-context-support-3.2.2.RELEASE.jarlibs/spring-core-3.2.2.RELEASE.jarlibs/spring-expression-3.2.2.RELEASE.jar需要:commons-logging-1.1.1.jar2、需要添加spring的配置文件配置文件的名称可以随便起名,但是最好有实际意义。例如:spring-dao.xmlspring-service.xmlspring.xml3、spring配置文件 怎么引入 beans约束---spring-framework-3.2.2.RELEASE-dist/spring-framework-3.2.2.RELEASE/docs/spring-framework-reference/html/index.html目录中:5.2.1. Configuration metadata 点击进去可以拷贝原信息:<?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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"></beans>4、下面就有实例化 :容器// 读取 classes 路径下面的文件 参数 动态参数、单个参数、数组 、可以使用通配符等ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");