gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 10:14:54 25 4
gpt4 key购买 nike

当我从 2.0.3.RELEASE 更改 Spring Boot 版本时,我有一个工作代码停止工作至2.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

或者 ...
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

这两种情况都与重复的bean os有关。

我的 POM 依赖项是:
    <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= : 被浏览器投诉 ERR_TOO_MANY_REDIRECTS但我在控制台中没有错误。无论如何......我的问题是:如何将我的 SpringBoot 更新为 2.1.0.BUILD-SNAPSHOT ?

最佳答案

这个答案可能对那些设置了新项目并添加 spring.main.allow-bean-definition-overriding: true 的人有所帮助。位于 application.properties 的属性(property)文件没有解决问题:
检查您的application.properties 所在的文件夹文件存在 - 它需要直接在目录下可用:src/main/resources/而不是其他任何地方。

关于spring-boot - 将 Spring Boot 版本从 2.0.3.RELEASE 更改为 2.1.0.BUILD-SNAPSHOT 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51367566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com