spring(1)

来源:互联网 发布:冰点文库下载器 mac版 编辑:程序博客网 时间:2024/05/16 23:47

简单搭建spring:   

commons-logging-1.1.3.jarspring-aop-4.0.5.RELEASE.jarspring-beans-4.0.5.RELEASE.jarspring-context-4.0.5.RELEASE.jarspring-core-4.0.5.RELEASE.jarspring-expression-4.0.5.RELEASE.jarspring-web-4.0.5.RELEASE.jar 
applicationContext.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"       xmlns:context="http://www.springframework.org/schema/context"       xmlns:aop="http://www.springframework.org/schema/aop"       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/beans http://www.springframework.org/schema/beans/spring-beans.xsd           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">   <context:component-scan base-package="test"></context:component-scan></beans>

java

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"applicationContext.xml"});

如果要以web方式启动

<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener></web-app>




0 0
原创粉丝点击