Spring Freamwork 开发初体验


工具
eclipse 
版本:Neon.3 Release (4.6.3)
Spring Freamwork
版本:4.0.4.RELEASE
下载地址:http://repo.springsource.org/libs-release-local/org/springframework/spring/4.0.4.RELEASE/
commons-logging-1.2-bin
下载地址:http://commons.apache.org/


创建工程
new java project
创建lib
手动添加进Spring Freamwork目录libs下的jar包(暂且全部引入)
referenced Libraries
添加lib包中jar
创建测试类
www.xi.com.Person

package www.xi.com;

public class Person {

	String name;

	public Person() {

	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "SpringTest [name=" + name + "]";
	}
}


www.xi.com.HelloSpring

package www.xi.com;

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

public class HelloSpring {

	public static void main(String[] args) {
//		Person st = new Person();
//		st.setName("Spring");
		
		ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
		Person p = (Person)ac.getBean("person1");
	
		System.out.println(p);
	
	}

}

创建
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"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans.xsd">
	
	
	<bean id="person1" class="www.xi.com.Person">
		<property name="name" value="xixiaohui" />
	</bean>
	
</beans>



问题:
1:Spring Tool Suite™ Downloads
连接地址:在Eclipse上安装Spring Tool Suite
http://blog.csdn.net/yerenyuan_pku/article/details/52787157
下载地址:https://spring.io/tools/sts/all
springsource-tool-suite-3.9.0.RELEASE-e4.6.3-updatesite.zip
这个版本的插件工具,与之前下载的Spring 4.0.4.RELEASE不一样了。


2.No embedded stylesheet
在xml文件窗口打开时点击运行,会出现这个问题,改成main文件窗口中执行程序。
3.applicationContext.xml
放在src目录下,下面的代码才能找到文件。
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值