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

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

相关文章

这篇文章主要介绍了spring的事务传播属性REQUIRED_NESTED的原...
今天小编给大家分享的是一文解析spring中事务的传播机制,相...
这篇文章主要介绍了SpringCloudAlibaba和SpringCloud有什么区...
本篇文章和大家了解一下SpringCloud整合XXL-Job的几个步骤。...
本篇文章和大家了解一下Spring延迟初始化会遇到什么问题。有...
这篇文章主要介绍了怎么使用Spring提供的不同缓存注解实现缓...