org.springframework.beans.factory.BeanDefinitionStoreException:Annotation-specified bean name xxx fo

今天遇到错误,搞了小半天

简单的例子
@Component
public class Person {
}
@Component("person")
public class Man{

}

报错
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.dfyang.TestApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name ‘person’ for bean class [com.dfyang.test.ConfigurationAndComponentAndBean.inter.impl.Person] conflicts with existing, non-compatible bean definition of same name and class [com.dfyang.test.ConfigurationAndComponentAndBean.inter.impl.Man]

解决——把@Component(“person”)里面的person改为其他名称就好了

猜你喜欢

转载自blog.csdn.net/dh554112075/article/details/80821719
今日推荐