简体   繁体   English

Spring Boot Client无法向管理员注册

[英]Spring Boot Client Failed to register with Admin

I have an Spring Boot Admin server running just fine. 我有一个运行良好的Spring Boot Admin服务器。 Here are the files: 这些是文件:

pom.xml

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <spring-boot-admin.version>2.1.0</spring-boot-admin.version>
</properties>

<dependencies>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server</artifactId>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server-ui</artifactId>
    </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <scope>test</scope>
      </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-dependencies</artifactId>
            <version>${spring-boot-admin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

application.properties

server.port = 9090
spring.application.name = adminserver

DemoApplication.java

@SpringBootApplication
@EnableAdminServer
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

This works great. 这很好。 I can navigate to http://localhost:9090/#/applications and see the admin server just fine. 我可以导航到http://localhost:9090/#/applications并查看管理服务器。 在此处输入图片说明

The problem is when I try to register one of my client applications to the server. 问题是当我尝试将我的一个客户端应用程序注册到服务器时。 Here are the details for my client application: 以下是我的客户应用程序的详细信息:

pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.0.RC1</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>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</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-hateoas</artifactId>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
        <version>1.5.7</version>
    </dependency>
</dependencies>

application.yml

spring:
  profiles: default
  boot:
    admin:
      url: http://localhost:9090
management:
  context-path: /actuator

When I start up the client application, I can navigate to http://localhost:8081/actuator/health and see all the health info just fine. 当启动客户端应用程序时,我可以导航到http://localhost:8081/actuator/health并查看所有运行状况信息。 But I also end up getting these errors in the console: 但是我最终也会在控制台中遇到这些错误:

DEBUG --- [   registrationTask1] de.codecentric.boot.admin.client.registration.ApplicationRegistrator                       : Failed to register application as Application [name=ClientApp, managementUrl=http://richard-desktop:8081/actuator/, healthUrl=http://richard-desktop:8081/actuator/health/, serviceUrl=http://richard-desktop:8081/] at spring-boot-admin ([http://localhost:9090/api/applications]): 404 Not Found 
DEBUG --- [   registrationTask1] de.codecentric.boot.admin.client.registration.ApplicationRegistrator                       : Failed to register application as Application [name=ClientApp, managementUrl=http://richard-desktop:8081/actuator/, healthUrl=http://richard-desktop:8081/actuator/health/, serviceUrl=http://richard-desktop:8081/] at spring-boot-admin ([http://localhost:9090/api/applications]): 404 Not Found 
DEBUG --- [   registrationTask1] de.codecentric.boot.admin.client.registration.ApplicationRegistrator                       : Failed to register application as Application [name=ClientApp, managementUrl=http://richard-desktop:8081/actuator/, healthUrl=http://richard-desktop:8081/actuator/health/, serviceUrl=http://richard-desktop:8081/] at spring-boot-admin ([http://localhost:9090/api/applications]): 404 Not Found 

What am I doing wrong here? 我在这里做错了什么?

Basically it failing to register because of difference in version of Spring Boot Admin Server(2.1.0) and Client(1.5.7). 基本上,由于Spring Boot Admin Server(2.1.0)和Client(1.5.7)版本的不同,它无法注册。

Client 1.5.7 hits at server with url //server:port/api/applications but server 2.1.0 expected registration at //server:port/instances path so just need to update the client to hit the expected server path. 客户端1.5.7使用URL // server:port / api / applications在服务器上命中,但服务器2.1.0预期在// server:port / instances路径上进行注册,因此只需要更新客户端以命中期望的服务器路径即可。

Just start the server/client in debug logs to get more hint on what url it trying to hit. 只需在调试日志中启动服务器/客户端即可获得有关其尝试访问的URL的更多提示。

Point to be noted here that We wont be getting all information due version uncompatability for many endpoints. 这里要指出的是,由于许多端点的版本不兼容,我们将不会获得所有信息。 Actuator module completely changed between 1.X and 2.X. 执行器模块在1.X和2.X之间完全更改。

With above point, below is workaround to get this done with limitations : 基于以上几点,以下是解决此问题的方法:

Client Java file : 客户端Java文件:

@SpringBootApplication
public class ClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(ClientApplication.class, args);
    }
}

Client Property file : 客户端属性文件:

server.port=8081
spring.boot.admin.url=http://localhost:8080
spring.boot.admin.api-path=/instances
management.security.enabled=false

Its working for me with limitations like not able to see metrics etc. but still handfull of information visible on Admin Server. 它对我的工作有一些限制,例如无法查看指标等,但是仍然有少量的信息在Admin Server上可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM