相关疑难解决方法(0)

将Spring Boot版本从2.0.3.RELEASE更改为2.1.0.BUILD-SNAPSHOT时出现问题

我有停止的时候,我从改变春节引导版本一起使用工作代码2.0.3.RELEASE2.1.0.BUILD-SNAPSHOT.

有时错误是:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

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

Description:

The bean 'dataSource', defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Run Code Online (Sandbox Code Playgroud)

要么 ...

Error starting ApplicationContext. To …
Run Code Online (Sandbox Code Playgroud)

spring-boot

27
推荐指数
1
解决办法
2万
查看次数

DataSource bean覆盖在spring boot 2.1中

我已升级到spring boot 2.1版本,启动应用程序时遇到奇怪的异常.

The bean 'dataSource', defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.
Run Code Online (Sandbox Code Playgroud)

完整的错误消息是:

[o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'dataSource' defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Cannot register bean definition [Root bean: class [org.springframework.aop.scope.ScopedProxyFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

21
推荐指数
3
解决办法
2万
查看次数

spring.main.allow-bean-definition-overriding=true 是一种不好的做法吗

我正在构建一个 Spring Boot Rest API 服务器,以便将遗留应用程序移植到更强大的框架上。这是我使用这些技术的第一个项目。到目前为止,我已经使用 2 个 API 构建了一个概念验证,可以回复“Hello world!” 在 JSON 中。一个是开放的,另一个是通过 OAuth2 保护的。我已经根据要求调整了安全性。

我还结合使用 Rest-Assured 进行集成测试和 Spring MockMvc 进行单元测试,构建了一个强大的测试结构,因此我相信我已经准备好开始使用 TDD 方法实现真正​​的 API。

我们正在使用 Maven。我的问题是,一旦我对现有工件产生依赖,我就会得到以下堆栈。我明白这意味着什么,但我们的代码库很大,我找不到它来自哪里。当我向 Google 询问这个问题时,我经常发现结果只是建议添加spring.main.allow-bean-definition-overriding=true到我的属性中。这不是把问题掩盖起来吗?我猜想 Spring 默认不允许这样做是有充分理由的。使用方便的应用程序属性简单地忽略该错误可能会产生什么后果?

堆栈:

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

Description:

The bean 'org.springframework.transaction.config.internalTransactionAdvisor', defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class], 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 …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

5
推荐指数
1
解决办法
8400
查看次数

标签 统计

spring-boot ×3

java ×2

spring ×2