有代码如下:
ConstructorBean.java:
package com.bean;public class ConstructorBean {
private ConstructorBean(int min, int max) {
System.out.println("min=" + min + "; max=" + max);
}
}
context.xml文档片段:
<bean id="constructorBean" class="com.bean.ConstructorBean" scope="singleton">
<constructor-arg value="100"></constructor-arg>
<constructor-arg value="200"></constructor-arg>
</bean>
测试类:
public static void main(String[] args) throws Exception {
new FileSystemXmlApplicationContext("classpath:context.xml");
}
运行结果:
min=100; max=200现有如下问题:
ConstructorBean的构造方法为私有的,spring是如何对其进行调用的.
ConstructorBean.java:
package com.bean;public class ConstructorBean {
private ConstructorBean(int min, int max) {
System.out.println("min=" + min + "; max=" + max);
}
}
context.xml文档片段:
<bean id="constructorBean" class="com.bean.ConstructorBean" scope="singleton">
<constructor-arg value="100"></constructor-arg>
<constructor-arg value="200"></constructor-arg>
</bean>
测试类:
public static void main(String[] args) throws Exception {
new FileSystemXmlApplicationContext("classpath:context.xml");
}
运行结果:
min=100; max=200现有如下问题:
ConstructorBean的构造方法为私有的,spring是如何对其进行调用的.
楼主【liye7881】截止到2008-07-24 20:18:17的历史汇总数据(不包括此帖):
发帖的总数量:5 发帖的总分数:43 每贴平均分数:8
回帖的总数量:6 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:5 结贴的总分数:43
无满意结贴数:2 无满意结贴分:40
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:40.00 % 无满意结分率:93.02 %
敬礼!