【问题标题】:Defining a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' in your configuration在配置中定义类型为 \'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs\' 的 bean
【发布时间】:2022-11-11 11:23:04
【问题描述】:

我正在将我的应用程序从 Spring Boot 版本 1.5.22.RELEASE 迁移到 2.5.5 以修复漏洞。在一个缓存定位器模块中,我使用 spring-boot-starter-data-gemfire 1.5.22.RELEASE 以及 com.gemstone.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.properties 文件中为此模块定义了配置为-

#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 Boot 版本 1.5 运行的服务.22.释放。

我该如何解决这个问题?

【问题讨论】:

    标签: spring-boot netflix-eureka spring-boot-migration-1.5.x-2.1.x


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-09-22
      • 2017-03-19
      • 1970-01-01
      • 2018-08-27
      • 2018-06-22
      • 1970-01-01
      • 2020-08-01
      • 2019-02-14
      • 2018-12-21
      相关资源
      最近更新 更多