1,could not be registered. A bean with that name has already been defined and overriding is disabled

在这里插入图片描述
有种方法:application配置文件里加一行:spring.main.allow-bean-definition-overriding: true 。当遇到同样名字的时候,是否允许覆盖注册(有时候会没用)

我这,直接在启动类中设置

  public static void main(String[] args) {
        SpringApplication application = new SpringApplication(new Class<?>[]{ResourceApplication.class});
        application.setAllowBeanDefinitionOverriding(true);
        application.run(args);
    }
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐