You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'simpleBean' defined in class path resource [test/Test-context.xml]: 1 constructor arguments specified but no matching constructor found in bean 'simpleBean' (hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)
Everything works fine (no exceptions) if
The public default constructor is removed or its signature is changed to accept some argument.
The access modifier of the zero argument constructor is anything less than public.
Good point, we should consistently find non-public multi-arg constructors there, even if public constructors with fewer or no arguments are declared in the same bean class. Fixed for 3.0.4.
Sajid Insaf opened SPR-7453 and commented
Spring appears to be unable to find constructors with arguments and access modifier less than public when default public constructor is present.
Consider the class:
package test;
public SimpleBean {
public SimpleBean() {}
private SimpleBean(String x) {}
}
Context configuration:
<bean id="simpleBean" class="test.SimpleBean">
<constructor-arg value="test" />
</bean>
Spring throws the following exception:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'simpleBean' defined in class path resource [test/Test-context.xml]: 1 constructor arguments specified but no matching constructor found in bean 'simpleBean' (hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)
Everything works fine (no exceptions) if
Affects: 2.5.6
Reference URL: http://forum.springsource.org/showthread.php?t=93609
Referenced from: commits 8a23ce9
The text was updated successfully, but these errors were encountered: