警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'guanYu': Unsatisfied dependency expressed through field 'weapon'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'cn.tedu.springdemo04.Weapon' available: expected single matching bean but found 2: dragonBlade,skyLancer
Spring报错:原因 @Autowired 此注解重复
解决方法:
使用@Qualifier 注解来解决Spring容器具体Id的对象注入到所定义的属性中
使用格式
@Autowired
@Qualifier("此处加Id")