加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

spring开发_注入其他Bean的方法返回值_MethodInvokingFactoryBea

发布时间:2020-12-15 01:52:37 所属栏目:大数据 来源:网络整理
导读:com.b510.app.test; org.springframework.context.ApplicationContext; org.springframework.context.support.ClassPathXmlApplicationContext; com.b510.service.AnimalService; SpringTest { main(String[] args) { ApplicationContext act= ClassPathXmlA

com.b510.app.test; org.springframework.context.ApplicationContext; org.springframework.context.support.ClassPathXmlApplicationContext; com.b510.service.AnimalService; SpringTest { main(String[] args) { ApplicationContext act= ClassPathXmlApplicationContext("beans.xml"); AnimalService dogServiceBean=(AnimalService) act.getBean("dog1"); System.out.println("获取dog1的年龄为:"+dogServiceBean.getAge()); AnimalService dogServiceBean2=(AnimalService) act.getBean("dog2"); System.out.println("获取dog2的年龄为:"+dogServiceBean2.getAge()); String info=(String) act.getBean("javaVersion"); System.out.println("系统的java版本是:"+info); } }

com.b510.app.util; ValueGenerator { getAgeValue() { 23; } getAgeStaticValue() { 20; } }

com.b510.service; AnimalService { setAge( age); getAge(); }

com.b510.service.impl; com.b510.service.AnimalService; DogServiceBean AnimalService { age; getAge() { age; } setAge( age) { .age = age; } }

xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http: ="com.b510.app.util.ValueGenerator"> ="com.b510.service.impl.DogServiceBean"> ="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> ="com.b510.service.impl.DogServiceBean"> ="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> ="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> ="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> java.version

2012-3-12 12:12:51 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1a05308: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1a05308]; startup date [Mon Mar 12 12:12:51 CST 2012]; root of context hierarchy 2012-3-12 12:12:51 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from path resource [beans.xml] 2012-3-12 12:12:54 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory 信息: Bean factory application context [org.springframework.context.support.ClassPathXmlApplicationContext@1a05308]: org.springframework.beans.factory.support.DefaultListableBeanFactory@bfc8e0 2012-3-12 12:12:54 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@bfc8e0: defining beans [valueGenerator,dog1,dog2,sysProps,javaVersion]; root of factory hierarchy 获取dog1的年龄为:23 获取dog2的年龄为:20 系统的java版本是:1.6.0_22

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读