在SpringBoot应用启动的过程中 报错
以下为报错信息:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.xxx.EmployeeBoot]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name ‘dataSourceController’ for bean class [com.xxx.managenment.controller.DataSourceController] conflicts with existing, non-compatible bean definition of same name and class [com.xxx.employee.controller.DataSourceController]
信息重点:
nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException
这个不是类名重复问题,是本人使用混合项目,多个项目在一个公共组件下,
启动的项目引用到了别的项目上导致报错.
以下是错误启动类
public class EmployeeBoot extends WebMvcConfigurerAdapter {
public static void main(String[] args) {
SpringApplication.run(managementSystem.class, args);
}
}
可以看到 本应该引用EmployeeBoot.class 可是启动确引用到了 managementSystem 项目上 所以启动失败
应该改为正确的启动类:
public class EmployeeBoot extends WebMvcConfigurerAdapter {
public static void main(String[] args) {
SpringApplication.run(EmployeeBoot.class, args);
}
}
可以正常启动~