在配置中定义类型为"com.netflix.discovery.AbstractDiscoveryClientOptionalArgs"的 bean



我正在从Spring引导版本1.5.22迁移我的应用程序。发布到2.5.5以修复漏洞。在一个缓存定位器模块中,我使用spring-boot-starter-data-gemfire 1.5.22。与com.gem .gemfire:gemfire:8.2.7, spring-cloud-starter-netflix-eureka-client版本3.1.0,&其他spring框架依赖项如-

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-gemfire</artifactId>
<version>1.5.22.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.gemstone.gemfire</groupId>
<artifactId>gemfire</artifactId>
</exclusion>
<exclusion>
<groupId>com.gemstone.gemfire</groupId>
<artifactId>gemfire</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.2.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson.core</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>3.1.0</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.1.5.Final</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.19</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.67</version>
</dependency>
<dependency>
<groupId>com.gemstone.gemfire</groupId>
<artifactId>gemfire</artifactId>
<version>8.2.7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.20</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.20</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.20</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>5.3.18</version>
</dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<version>2.5.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId></groupId>
<artifactId></artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

该模块的主类为-

@SpringBootApplication
@ImportResource({"gemfire-locator.xml"})
@EnableEncryptableProperties
public class LocatorApp {
public static void main(final String[] args) { 
SpringApplication.run(LocatorApp.class, args);
}
}

我在application-local中定义了配置。属性文件为-

#spring.profiles.active=local
#spring.profiles.include=pulse.authentication.custom
spring.profiles.groups.local=pulse.authentication.custom
spring.application.name=gemfirelocator
server.hostname=#{T.........}
server.port=9020
gemfire.properties.location=/gemfire/gemfire-locator-local.properties
data.location=.

当我尝试启动此服务时,我得到以下错误-

Field optionalArgs in org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration required a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' in your configuration.
The injection point has following annotations:
@org.springframework.beans.factory.annotation.Autowired(required=true)

我试图改变并尝试使用其他版本的netflix-eureka-client,我也试图在这个pom.xml文件中删除许多排除的依赖项,但没有任何帮助启动我的服务,我能够运行spring引导版本1.5.22.RELEASE。

如何解决这个问题?

我的问题是缺少web依赖项。您可以将下列依赖项添加到pom.xml文件中。

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

我通过检查Spring Boot和Spring Cloud版本兼容性解决了这个问题。以前我有:Spring Boot(3.1.1)和Spring Cloud(2022.0.3),这给了我这个错误。我更新到Spring Boot(3.0.5)和Spring Cloud(2022.0.1),错误消失了。

添加此依赖项来解析


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

确保在主类上使用了@EnableEurekaServer

@SpringBootApplication
@ImportResource({"gemfire-locator.xml"})
@EnableEncryptableProperties
@EnableEurekaServer
public class LocatorApp {
public static void main(final String[] args) { 
SpringApplication.run(LocatorApp.class, args);
}
}

最新更新