Spring之config.xml配置

以下三行必写,不能更改

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

Bean的类:

<bean id="aGoodName" class="com.xxx.xxx">

Singleton使用:
在Spring中,Bean可以被定义为两种部署模式中的一种,Singleton和non-singleton,意思是要么(默认为Singleton)共享一个实例,每次请求只会返回这个唯一实例,要么(non-singleton)对Bean的每次请求都会创建一个新实例

<bean id="aGoodName" class="com.xxx.xxx" singleton="true">
<!--此句中singleton加与不加效果是一样的-->

注入方式:
setter、接口、 构造器三种方式。分别为:

<constructor-arg index="0">
<value>HelloWorld</value>
</constructor-arg>

使用Depend on时,依赖的Bean必须先初始化

<bean id="aGoodName" class="com.xxx.xxx" depends-on="date">

Bean的引用必须用ref

        <property name="date" >
            <ref bean="date"/>
        </property>
    </bean>
    <bean id="date" class="java.util.Date"/>
</beans>
<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值