package com.ls.spring.ioc.dummy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class A {
@Autowired
private B b;
public A() {
super();
}
public A(B b) {
super();
this.b = b;
}
public B getB() {
return b;
}
public void setB(B b) {
this.b = b;
}
}
package com.ls.spring.ioc.dummy;
import org.springframework.stereotype.Component;
@Component
public class B {
public void put() {
System.out.println("B is outing...");
}
}
a.(class)=com.ls.spring.ioc.dummy.A
b.(class)=com.ls.spring.ioc.dummy.B
a.$0(ref)=b
#---setter injection---
#a.b(ref)=b
package com.ls.spring.ioc.dummy;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
public class TestBeanFactoryViaProperties {
public static void main(String[] args) {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(factory);
reader.loadBeanDefinitions("classpath:com/ls/spring/ioc/dummy/ioc-test.properties");
A a = (A) factory.getBean("a");
a.getB().put();
}
}
分享到:
相关推荐
properties文件获取工具类:静态加载properties配置文件,有根据key获取值的方法
IDEA WEB项目启动不加载application.properties配置文件,yml配置文件是否也会不加载未尝试,如果有遇到的可以尝试一下。
SSM框架下的几种加载properties配置文件方式,博客内含介绍https://blog.csdn.net/weixin_42803662
加载src目录下的properties配置文件,返回TreeMap键值对,方便获取连接时调用
c#操作properties,读写配置文件,非常方便,几行代码就搞定
主要介绍了 log4j.properties配置与加载应用的相关资料,需要的朋友可以参考下
可以从Jar外部加载JDBC.properties的Spring-mybatis配置文件,直接可以用,适合部署可执行jar时,从外部配置数据库
Spring3.0 配置文件中加载Properties文件的小例子
ConfigFile configfile = ConfigFile.getInstance("ipConfig123.properties"); String ip = configfile.getkeyvalue("ip"); 可以取出ipConfig123.properties 文件中IP的内容
主要介绍了详解SpringMVC加载配置Properties文件的几种方式,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
使用Java中的Properties类的方法,以及类加载器来读取配置文件中的信息。可以读取.properties文件和.cfg文件。详细代码+注释+测试例子
Apache Commons Configuration对properties、xml配置文件的【增删改查】及动态加载小案例。小编也是找了网上很多资源,综合研究了一下。被怪我黑!!!
在web应用用写的一些Socket服务等,需要配置IP、端口等信息,我们希望这些信息写到配置文件中,并有spring帮我们加载。
配置文件加载类 就是读取资源属性文件(properties),然后根据.properties文件的名称信息(本地化信息),匹配当前系统的国别语言信息(也可以程序指定),然后获取相应的properties文件的内容。.
在网上都是esapi包,此处将esapi的3个配置文件打包上传,方便各位配置
springboot 的配置文件加载顺序 https://blog.csdn.net/dearmite/article/details/131045230 本系列校训 用免费公开视频,卷飞培训班哈人!打死不报班,赚钱靠狠干! 只要自己有电脑,前后项目都能搞!N年苦学无人...
主要介绍了Python实现加载及解析properties配置文件的方法,结合实例形式分析了Python针对properties配置文件的加载、读取及解析相关操作技巧,需要的朋友可以参考下
本文实例讲述了Python实现读取Properties配置文件的方法。分享给大家供大家参考,具体如下: JAVA本身提供了对于Properties文件操作的类,项目中的很多配置信息都是放在了Properties文件。但是Python并没有提供操作...
将classpath路径下的配置文件加载进properties集合,并实现Student接口,多态形式,提高程序的可维护性