关于Bean重新注册的问题

最近在整理springsecurity时,发现一个问题
The bean 'metaDataSourceAdvisor',could not be registered.A bean with that name has already been defined
找了半天,看报错也知道某个Bean重复注册了,但是思来想去老子没有自定义这玩意啊,
于是乎全局搜索

原来如此,speingsecurity里面的,后来检查发现

 

@EnableGlobalMethodSecurity(prePostEnabled = true)

这个注解除了在启动类上有,在我实现的配置类上也有,于是把配置类上的去掉即可。

but    springboot提示考虑# 遇到相同名字时,是否允许覆盖注册
  main:
    allow-bean-definition-overriding: true
在配置文件里加上这个注解,我的建议是,检查下需不需要覆盖,万一你覆盖了,关键的代码有调用顺序不就歇菜了吗,

 

posted @ 2022-11-20 17:52  余生请多指教ANT  阅读(609)  评论(0编辑  收藏  举报