spring-ioc的基本配置(applicationContext.properties)

本文深入探讨了Spring框架中beans.xml文件的配置细节,包括抽象类的使用、bean实例的创建、属性注入以及如何通过PropertyPlaceholderConfigurer加载配置文件。重点介绍了如何在不同场景下灵活配置bean,以及配置文件的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0" encoding="GB18030"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="abstactother" abstract="true"> <constructor-arg value="${constructor}" /> </bean> <bean id="other" class="Other" parent="abstactother" scope="prototype"> <property name="string" value="${other}" /> </bean> <bean id="bean" factory-bean="otherFactory" factory-method="getIOther" /> <bean id="otherFactory" class="OtherFactory"> <property name="string" value="${string}" /> </bean> <bean class="OtherFactory"/> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="applicationContext.properties"/> </bean> <bean id="method" class="OtherFactory" factory-method="getOther" /> <!-- 注册监听器 --> <bean class="Listener"></bean> </beans>

string=<property name="string" value='' /> constructor=<constructor-arg value=''/> strings=spring,struts,hibernate date=2012-01-09 other=<property name='string' value='' /> list=<property name='list'><list><value></value></list></property> set=<property name='set'><set><value></value></set></property> map=<property name='map'><map><entry key='map' value='' /></map></property> prop=<property name='properties'><props><prop key='prop'></prop></props></property>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值