当前位置: 首页 > 面试题库 >

定义为null的bean'metaDataSourceAdvisor'无法注册

李明贤
2023-03-14
问题内容

我已经将Spring Boot版本从2.0.3更新到2.1.1,但是我得到了:

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'metaDataSourceAdvisor', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

我得到了错误-问题是defined in null在哪里看并不是一个好的指针。我已经看到了这个问题,但是我实际上更愿意继续禁止覆盖不明确的豆类。

有任何想法吗?

日志输出

2019-01-06 07:33:39.282  INFO 29626 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-01-06 07:33:39.282  INFO 29626 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-01-06 07:33:39.912  INFO 29626 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-01-06 07:33:39.997  INFO 29626 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 80ms. Found 23 repository interfaces.
2019-01-06 07:33:39.999  WARN 29626 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'metaDataSourceAdvisor' defined in null: Cannot register bean definition [Root bean: class [org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'metaDataSourceAdvisor': There is already [Root bean: class [org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2019-01-06 07:33:40.008  INFO 29626 --- [  restartedMain] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-06 07:33:40.010 ERROR 29626 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :

问题答案:

好的,我自己发现了这个问题:我@EnableGlobalMethodSecurity在项目中有两次:

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true) // <--
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
}

@SpringBootApplication
@EnableJpaRepositories(basePackages = {"mz.server.spring.repository"})
@EnableGlobalMethodSecurity(prePostEnabled = true, proxyTargetClass = true) // <--
@EntityScan(basePackages = "mz.server.hibernate.model")
@EnableTransactionManagement
@EnableScheduling
public class Application {
}

所以我想说这是一个很好的Spring Boot新功能。

如果您看到这种错误,只需小心不要重复的注释。



 类似资料:
  • 我正在做一个简单的博客后端,作为一个个人项目。我这样做是为了尝试获取一些JavaSpring,我对下面的代码有问题(有很多...)。 我得到的错误正是这样的:定义为null的bean“postRepository”无法注册。已在null中定义了具有该名称的bean,并且已禁用重写。 代码本身在最初使用Hibernate时运行良好,我有2个DAO,2个DAOMPLS,并使用服务类中的DAOMPLS调

  • 获取错误。我尝试做多个选择,并更改第二个选择的数据与第一个选择的上更改材料表行。我正在使用Firebase。 当“store.Urunler”为null或未定义时,我会出现此错误。而且我的产品没有列在菜单项上,这意味着选择是空的,但state.products有数据 我怎样才能克服这个错误。我还想添加到Urunler,选择一个输入。我知道我应该为onChanges调用函数,但如果它起作用,我以后会

  • 我正在运行一个React应用程序。 当我通过路由(单击按钮或链接)进入页面时,页面工作正常,但当我重新加载页面时,页面崩溃。我看不到错误在哪里,控制台和源代码显示为空,这是服务器消息控制台消息。 这是运行的代码。我尝试删除currentuser、addhabity和许多其他东西,只是为了了解错误的来源。没有结果。如果我通过链接进入页面,一切正常。 HabiddView.web.jsx 生活orm.

  • 我正在我的反应应用程序中创建一个上一个和下一个按钮。我试图获取页面的当前索引(我有一个存储在对象中的页面列表) 这是密码 我得到的错误是“类型错误:无法将未定义或空转换为对象” 需要明确的是,imageName和images不是空的或未定义的(因为当I console.log它时,它有我需要的数据)。 提前谢谢!

  • 问题内容: 当我编写手表处理函数时,我会在和上检查newVal参数。为什么AngularJS具有这种行为,却没有特定的实用程序方法?所以有但没有。手动实现并不难,但是如何扩展角度以在每个控制器中具有该功能?Tnx。 编辑 : 这个例子: 处理这种方法是否普遍接受? 编辑2 : JSFiddle示例(http://jsfiddle.net/ubA9r/): 问题答案: 您始终可以为您的应用程序完全添