当前位置: 首页 > 知识库问答 >
问题:

将Spring Boot版本从2.0.3.release更改为2.1.0.build-snapshot时出现的问题

苏凯
2023-03-14
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
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-16 14:38:18.509 ERROR 604 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

The bean 'scopedTarget.oauth2ClientContext', defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2RestOperationsConfiguration$SessionScopedConfiguration$ClientContextConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/security/oauth2/config/annotation/web/configuration/OAuth2ClientConfiguration$OAuth2ClientContextConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/> 
    </parent>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
        <maven.test.skip>true</maven.test.skip>
    </properties>   


   <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>        
         <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>       
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>          
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>        
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-oauth2</artifactId>
        </dependency>


        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
        </dependency>   
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>       


    </dependencies>
server:
  error:
    include-stacktrace: always
    whitelabel:
      enabled: false
  servlet:
   session:
    cookie:
     name: HYDRASSESSION
  port: 36205


management:
  endpoints:
    web:
      exposure:
        include: "*"


security:
  basic:
    enabled: false
  oauth2:
      client:
        clientId: atlas
        clientSecret: secret
        accessTokenUri: http://myserverip:36202/oauth/token
        userAuthorizationUri: http://myserverip:36202/oauth/authorize
      resource:
        userInfoUri: http://myserverip:36202/user/me


spring:
  jpa:
    properties:
      hibernate:
        temp:
          use_jdbc_metadata_defaults: false 
    hibernate:
      ddl-auto: validate
  application:
    name: atlas
  datasource:
    password: admin
    username: postgres
    url: jdbc:postgresql://myserverip:36211/atlas?ApplicationName=Atlas

guardiao:
  logout:
    path: http://myserverip:36202/exit

它在使用2.0.3时运行良好。release但是我在尝试登录myserver:36202/oauth/authorize时收到一个错误?client_id=:by browser complainserr_too_many_redirects但是我在控制台中没有错误。不管怎样...我的问题是:如何将SpringBoot更新到2.1.0.build-snapshot?

共有1个答案

王嘉木
2023-03-14

因此,正如异常报告的那样,有两个相同类型的bean。历史上,Spring会用一个bean覆盖另一个bean。这一直是一个麻烦,因为您可能很难找到bug,因为第二个bean具有完全不同的类型,但具有相同的bean ID会使您的第一个bean消失。

Spring Boot2现在默认禁用这种bean覆盖。您可以通过在application.yml中设置以下属性来重新启用它:

spring.main.allow-bean-definition-overriding: true

这将重新启用前面的行为。但是,它并没有解决bean被重写的根本原因,也意味着您不会从bean重写错误中获得好处。随着时间的推移,升级底层库有望清除这种情况。

 类似资料:
  • 从2.1.0迁移的Springboot版本2.2.1

  • 我有在android studio中使用php sql进行登录活动的代码,代码如下:- 有了21个sdk版本,它工作得非常完美,但当我尝试将gradle文件更改为25版本时,在http连接代码下出现了许多红线 那么解决方案是什么?我如何将sdk升级到25而不出现任何问题?非常感谢

  • 也许我需要添加appcompat_v_7,我尝试过,但每次它都给我很多错误

  • 问题内容: 我不太确定自己是如何陷入困境的,但是由于某种原因,我无法使用替代方法来更改Java的当前版本。我可以运行其他选项–config java并输入选择内容,但是当我回显java或javac的版本号时,它每次都会吐出1.5(尽管其他选项显示当前版本为1.6)。顺便说一下,我正在使用的服务器正在运行RHEL5。 我已验证替代方法中使用的路径指向正确的目录。这是我的会话的一些输出: [brile

  • 问题内容: 我想使用一些需要Python的较新软件,并且我们目前已将它们同时安装在专用的CentOS服务器上,如下所示: 如何切换为默认使用? 问题答案: 作为根: 这将从/ usr / local / bin / python-> /usr/bin/python2.6建立符号链接(替换旧的硬链接)。

  • 我在intellij IDEA中更改了jdk版本后遇到了一个问题。 在我的pom文件中,我有下一个属性: 并且当maven在控制台启动build Project-at显示JDK-1.8的正确版本时: 但当我尝试启动project时,控制台显示JDK:的早期版本 有谁能帮我解决这个问题吗?