Spring构造方法注入时,注入一种方法时正常注入多种时报错

   阅读
Spring构造方法注入时,注入一种方法时正常注入多种时报错,求助

package test;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
//import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
//import org.springframework.beans.factory.xml.XmlBeanFactory;
//import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
//import org.springframework.core.io.ClassPathResource;

public class MockBusinessObject {
private String dependency1;
private int dependency;
public MockBusinessObject(String dependency)
{
this.dependency1 = dependency; 
}
public MockBusinessObject(int dependency)
{
this.dependency = dependency;
}
public int getMockBusinessObject(int dependency)
{
return dependency;
}
@Override
public String toString() {
return new ToStringBuilder(this).append("dependency1", dependency1).append("dependency", dependency).toString();
}
public static void main(String[] args)
{
DefaultListableBeanFactory beanRegistry = new DefaultListableBeanFactory();
BeanFactory container = (BeanFactory)bindViaXMLFile(beanRegistry);
MockBusinessObject mockBusinessObject = (MockBusinessObject)container.getBean("MockBusinessObject");
System.out.println(mockBusinessObject.toString());
}
public static BeanFactory bindViaXMLFile(BeanDefinitionRegistry registry) 
{
//XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
//reader.loadBeanDefinitions("classpath:/test/NewFile.xml");
//return (BeanFactory)registry;
//return new XmlBeanFactory(new ClassPathResource("/test/NewFile.xml"));
return new ClassPathXmlApplicationContext("classpath:/test/NewFile.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:util="http://www.springframework.org/schema/util" 
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang" 
xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd 
http://www.springframework.org/schema/jee 
http://www.springframework.org/schema/jee/spring-jee-2.0.xsd 
http://www.springframework.org/schema/lang 
http://www.springframework.org/schema/lang/spring-lang-2.0.xsd 
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean id="MockBusinessObject" class="test.MockBusinessObject">
    <constructor-arg index="0" value="111111"/>
    <constructor-arg index="1" value="222222"/>
</bean>
</beans>

如果只注入value="111111",下一行注释掉就正常,加上第二行就报错如下
一月 17, 2014 3:56:08 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@15b011c: startup date [Fri Jan 17 15:56:08 CST 2014]; root of context hierarchy
一月 17, 2014 3:56:09 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [test/NewFile.xml]
一月 17, 2014 3:56:10 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@699df5: defining beans [MockBusinessObject]; root of factory hierarchy
一月 17, 2014 3:56:10 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory destroySingletons
信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@699df5: defining beans [MockBusinessObject]; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MockBusinessObject' defined in class path resource [test/NewFile.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)
阅读