博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring入门教程:通过MyEclipse开发第一个Spring项目
阅读量:4356 次
发布时间:2019-06-07

本文共 937 字,大约阅读时间需要 3 分钟。

 

 

 

 

 

 

 Animal.java

package com.project;public class Animal {    private String name;    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }}

 Main.java

package com.project;import org.springframework.beans.factory.BeanFactory;import org.springframework.beans.factory.xml.XmlBeanFactory;import org.springframework.core.io.ClassPathResource;import org.springframework.core.io.Resource;public class Main {    public static void main(String[] args) {        Resource resource=new ClassPathResource("applicationContext.xml");        BeanFactory beanFactory=new XmlBeanFactory(resource);        Animal animal=(Animal)beanFactory.getBean("animal");        System.out.println(animal.getName());    }}

 applicationContext.xml

Dog

运行结果:

转载于:https://www.cnblogs.com/taoweiji/p/3598125.html

你可能感兴趣的文章
【Golang 接口自动化08】使用标准库httptest完成HTTP请求的Mock测试
查看>>
洛谷 P1036 选数
查看>>
女性社区TOP10
查看>>
BP神经网络算法推导及代码实现笔记zz
查看>>
前端必读:浏览器内部工作原理
查看>>
每天一个Linux命令(16)--which命令
查看>>
libevent文档学习(一)多线程接口和使用
查看>>
【补hackbar的坑】关于hackbar需要钱的补救措施
查看>>
纤程与Quasar
查看>>
MySQL的一个麻烦事
查看>>
Uri、URL和URN三者的区别
查看>>
数据字典的转换
查看>>
二维数组按照指定的字段排序的函数
查看>>
在IAR下通过Jlink将程序直接下载到Flash指定地址
查看>>
POJ2560-雀斑(Freckles)【图论,并查集,最小生成树,KURUSKAL】
查看>>
[Angular] Tree shakable provider
查看>>
[Vue + TS] Use Dependency Injection in Vue Using @Inject and @Provide Decorators with TypeScript
查看>>
[Angular 2] Select From Multiple Nested Angular 2 Elements
查看>>
C# 中的委托和事件[转帖]
查看>>
图的遍历(bfs+dfs)模板
查看>>