spring框架自带的bean配置文件模板-beanConfigurerTests.xml

本文提供了一个Spring框架中bean配置文件的示例,详细展示了不同类型的bean定义及其属性设置方式,包括懒加载、依赖注入等特性。

spring框架自带的bean配置文件模板-beanConfigurerTests.xml<?xml version="1.0" encoding="UTF-8"?>


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:context="http://www.springframework.org/schema/context"
		xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

	<context:spring-configured/>

	<context:annotation-config/>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$WireArbitraryExistingPojo"
			factory-method="aspectOf"/>

	<bean id="beanOne" class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$ShouldBeConfiguredBySpring"
			lazy-init="true">
		<property name="name" value="Rod"/>
	</bean>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$ShouldBeConfiguredBySpringUsingTypeNameAsBeanName"
			lazy-init="true">
		<property name="name" value="Rob"/>
	</bean>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$SubBean"
			lazy-init="true">
		<property name="name" value="Ramnivas"/>
	</bean>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$SubBeanPreConstruction"
			lazy-init="true">
		<property name="name" value="Ramnivas"/>
	</bean>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$SubSerializableBean"
			lazy-init="true">
		<property name="name" value="Ramnivas"/>
	</bean>
	
	<bean id="circular" class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$CircularFactoryBean"
			autowire-candidate="false"/>
	
	<!-- Used as a target for autowiring by type -->
	<bean id="ramnivas" class="org.springframework.beans.TestBean" depends-on="circular">
		<property name="name" value="Ramnivas"/>
		<property name="spouse" ref="circular"/>
	</bean>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$ArbitraryExistingPojo">
		<property name="friend" ref="ramnivas"/>
	</bean>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$PreConstructionConfiguredBean">
		<property name="name" value="ramnivas"/>
	</bean>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$PostConstructionConfiguredBean">
		<property name="name" value="ramnivas"/>
	</bean>

	<bean class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$GenericParameterConfigurableBean" scope="prototype">
		<property name="testService" ref="testService"/>
	</bean>

	<bean id="testService" class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$TestService"/>
	<bean id="paymentService" class="org.springframework.beans.factory.aspectj.BeanConfigurerTests$PaymentService"/>

</beans>


还有另一个模板 applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:aop="http://www.springframework.org/schema/aop"
		xmlns:context="http://www.springframework.org/schema/context"
		xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
				http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

	<context:spring-configured/>

	<aop:aspectj-autoproxy/>

</beans>


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值