Eclipse集成Spring(最基本配置)

最基本的JAR包和目录:


Spring.XML配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
	<bean id="adBean" class="com.xt.adspring.bean.ADBean">
	</bean>
</beans>

Launcher.java文件:

package com.xt.adspring.launch;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.xt.adspring.bean.ADBean;

public class Launcher {
	
	public static void main(String[] args) {
		ApplicationContext ctx = new FileSystemXmlApplicationContext("src/Spring.xml");
		ADBean bean = (ADBean)ctx.getBean("adBean");
		bean.print();
	}
}

ADBean.java文件:

package com.xt.adspring.bean;

public class ADBean {
	public void print() {
		System.out.println("Hello Spring...");
	}
}








你可能感兴趣的:(Eclipse集成Spring(最基本配置))