问题描述
Error creating bean with name ‘xxx’ defined in class path resource [beans.xml]: Unsatisfied dependency expressed through constructor parameter 1: Ambiguous argument values for parameter of type [int] - did you specify the correct bean references as arguments?
Exception in thread “main” org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘user’ defined in class path resource [beans.xml]: Unsatisfied dependency expressed through constructor parameter 1: Ambiguous argument values for parameter of type [int] - did you specify the correct bean references as arguments?
原因分析:
原因:一个bean混合使用p命名空间注入和c命名空间注入
<bean id="user" class="com.peng.pojo.User" c:name="hbl" p:age="18"/>
解决方案:
注入同一个bean的属性时,不能混合使用p命名空间注入和c命名空间注入
(错误很偏,完全粗心大意导致,但在学习的时候就是粗心出现了这个错误,并且搜索没有找到解答,最后自己检查的时候才发现)