Spring myeclipse配置
来源:互联网 发布:淘宝上哪家卖玉的店铺 编辑:程序博客网 时间:2024/05/19 04:05
参考文献:http://blog.csdn.net/lzm18064126848/article/details/48196513
Spring实现了输入不同的字符串返回不同的新对象的功能,而且这些映射写在xml文件中
1.自动配置方式
没有addSpringCapabilities?
右击web项目——properties——Myeclipse-----ProjectFacets——勾选上Spring----ok
然后
变成了
项目图标的J变成了S,这说明我的项目已经支持Spring了么?
代码与手动配置的代码是一致的的
2.手动配置方式
2.1 添加Spring的jar包
将Spring-framwork压缩包libs目录下的所有jar包和
Struts压缩包lib下的commoms-logging包添加到myeclipse
2.2配置文件和代码
①applicationContext.xml
<?xmlversion="1.0"encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<beanid="northMan"class="demo.Northperson"></bean>
<beanid="southMan"class="demo.SouthPerson"></bean>
</beans>
②Person.java
package demo;
public interfacePerson {
void eat();//定义抽象的吃方法
voiddrink();//定义抽象的喝方法
}
③Northperson.java
package demo;
public classNorthperson implements Person{
@Override
public void eat() {
// TODO Auto-generated method stub
System.out.println("北方人喜欢吃面食");
}
@Override
public void drink() {
// TODO Auto-generated method stub
System.out.println("北方人喜欢喝酒");
}
}
④SouthPerson
package demo;
public classSouthPerson implements Person{
@Override
public void eat() {
// TODO Auto-generated method stub
System.out.println("南方人喜欢吃饭");
}
@Override
public void drink() {
// TODO Auto-generated method stub
System.out.println("南方人喜欢喝茶");
}
}
⑤Test
package demo;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public classTest {
publicstaticvoidmain(String[]args){
ApplicationContext ac=newFileSystemXmlApplicationContext("src/applicationContext.xml");//利用文件系统查询applicationContext.xml配置文件
Northperson n=(Northperson)ac.getBean("northMan");
n.eat();
n.drink();
SouthPerson s=(SouthPerson)ac.getBean("southMan");
s.eat();
s.drink();
}
}
- myeclipse中配置spring
- myEclipse 6.5 spring配置
- myeclipse配置spring
- Spring myeclipse配置
- MyEclipse配置struts+hibernate+spring
- MyEclipse配置struts+hibernate+spring
- myEclipse struct2+spring+hibernate配置
- 图解MyEclipse配置struts+hibernate+spring+FreeMarker
- 图解MyEclipse配置struts+hibernate+spring+FreeMarker
- 图解MyEclipse配置struts+hibernate+spring+FreeMarker
- 图解MyEclipse配置struts+hibernate+spring
- 图解MyEclipse配置struts+hibernate+spring+FreeMarker
- 图解MyEclipse配置struts+hibernate+spring
- 图解MyEclipse配置struts+hibernate+spring
- 图解MyEclipse配置struts+hibernate+spring
- 图解MyEclipse配置struts+hibernate+spring+FreeMarker
- 图解MyEclipse配置struts+hibernate+spring+FreeMarker
- Myeclipse+struts2.0.11+hibernate+spring配置
- dp之01背包(从二维到一维)+完全背包
- 【怎样写代码】确保对象的唯一性 -- 单例模式(一):问题案例
- springMVC 处理json 及 HttpMessageConverter 接口
- Faster RCNN、SSD和YOLOv2的结果比较
- User's Guide Of Dagger2
- Spring myeclipse配置
- 以主角为起点,周围的草根据位置透明显示
- 通过 Spring Security配置 解决X-Frame-Options deny 造成的页面空白
- 扫地机器人排行榜 扫地机器人哪个牌子好?
- 任务1:把一张图附到另一张图上(c++结合opencv)
- pycharm 教程(二)设置字体大小
- Linux中TCP listen()的参数
- Java8源码-Stack
- 概率基础1-事件与概率