ITCAST视频-Spring学习笔记(搭建与测试Spring的开发环境)
2009-01-29 15:24
916 查看
感谢ITCAST发布的免费视频。
spring version:2.5.6
Spring需要的jar
到http://www.springsource.org/download下载spring,然后进行解压缩,在解压缩目录中找到下面的jar文件,拷贝到类路径下
dist\spring.jar
lib\jakarta-commons\commons-logging.jar
如果使用AOP还需要下列jar文件
lib/aspectj/aspectjweaver.jar和aspectjrt.jar
lib/cglib/cglib-nodep-2.1.3.jar
如果使用了JSR-250中的注解,如@resource/@PostConstruct/@PreDestroy还需要下列jar
lib/j2ee/common-annotations.jar
配置文件模版:
<?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-2.5.xsd">
<bean id="..." class="...">
<!-- collaborators and configuration for this bean go here -->
</bean>
<bean id="..." class="...">
<!-- collaborators and configuration for this bean go here -->
</bean>
<!-- more bean definitions go here -->
</beans>
该模版可以从spring的参考手册中得到。配置文件的取名可以任意,文件可以存放在任何目录下,但考虑到通用性,一般放在类路径下。
实例化spring容器
两种方式:
方法一:
在类路径下寻找配置文件来实例化容器
ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{“beans.xml”});
方法二:
在文件系统路径下寻找配置文件来实例化容器
ApplicationContext ctx = new FileSystemXmlApplicationContext(new String[] {“d:\\beans.xml”});
Spring的配置文件可以指定多个,可以通过String数组传入
Bean有id和name属性,id不能包含特殊字符,如果需要使用特殊字符,那么就需要使用name,一般使用id即可
spring version:2.5.6
Spring需要的jar
到http://www.springsource.org/download下载spring,然后进行解压缩,在解压缩目录中找到下面的jar文件,拷贝到类路径下
dist\spring.jar
lib\jakarta-commons\commons-logging.jar
如果使用AOP还需要下列jar文件
lib/aspectj/aspectjweaver.jar和aspectjrt.jar
lib/cglib/cglib-nodep-2.1.3.jar
如果使用了JSR-250中的注解,如@resource/@PostConstruct/@PreDestroy还需要下列jar
lib/j2ee/common-annotations.jar
配置文件模版:
<?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-2.5.xsd">
<bean id="..." class="...">
<!-- collaborators and configuration for this bean go here -->
</bean>
<bean id="..." class="...">
<!-- collaborators and configuration for this bean go here -->
</bean>
<!-- more bean definitions go here -->
</beans>
该模版可以从spring的参考手册中得到。配置文件的取名可以任意,文件可以存放在任何目录下,但考虑到通用性,一般放在类路径下。
实例化spring容器
两种方式:
方法一:
在类路径下寻找配置文件来实例化容器
ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{“beans.xml”});
方法二:
在文件系统路径下寻找配置文件来实例化容器
ApplicationContext ctx = new FileSystemXmlApplicationContext(new String[] {“d:\\beans.xml”});
Spring的配置文件可以指定多个,可以通过String数组传入
Bean有id和name属性,id不能包含特殊字符,如果需要使用特殊字符,那么就需要使用name,一般使用id即可
相关文章推荐
- spring学习笔记整理--02(搭建与测试Spring的开发环境)
- spring2.5.6学习笔记三:搭建与测试Spring的开发环境
- Spring学习笔记(一)环境搭建和测试开发环境
- Spring学习笔记(一)环境搭建和测试开发环境
- Java学习笔记38:通过Spring Bean 注入static变量,来设计一套适合测试,开发,生产环境的配置项
- Spring学习笔记02---搭建开发环境
- Spring 学习笔记2 Spring开发环境搭建
- Java框架学习笔记——Spring开发环境搭建
- ITCAST视频-Spring学习笔记(Spring如何装配各种集合类型的属性)
- Scala学习笔记(2):开发环境的搭建
- hadoop学习笔记(3)-eclipse下搭建hadoop开发环境各种问题的解决
- [liferay 学习笔记]搭建liferay的开发环境
- structs2的学习笔记----(helloworld开发环境的搭建)
- ios学习笔记(一)Windows7上使用VMWare搭建iPhone开发环境(转)
- XMPP协议学习笔记六(搭建Tigase开发环境)
- 区块链学习笔记(一)Ethereum-Go开发环境搭建
- Spring 4 学习笔记-环境搭建
- Spring学习之开发环境搭建的详细步骤
- ios学习笔记(一)Windows7上使用VMWare搭建iPhone开发环境
- Struts2学习笔记之开发环境搭建