Spring Boot管理员页面

我试图了解如何在我的应用程序中使用SBAP,因为它是非常方便的开发工具。我正在阅读他们的参考指南,但是我不了解一些事情。这是我现在申请的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<packaging>war</packaging>

<groupId>com.batch.books.test</groupId>

<artifactId>test</artifactId>

<version>0.0.1-SNAPSHOT</version>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.3.1.RELEASE</version>

</parent>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-actuator</artifactId>

<version>1.3.1.RELEASE</version>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

<version>1.3.1.RELEASE</version>

</dependency>

<dependency>

<groupId>ch.qos.logback</groupId>

<artifactId>logback-classic</artifactId>

<version>1.1.3</version>

</dependency>

<dependency>

<groupId>de.codecentric</groupId>

<artifactId>spring-boot-admin-server</artifactId>

<version>1.3.2</version>

</dependency>

<dependency>

<groupId>de.codecentric</groupId>

<artifactId>spring-boot-admin-server-ui</artifactId>

<version>1.3.2</version>

</dependency>

<dependency>

<groupId>de.codecentric</groupId>

<artifactId>spring-boot-admin-starter-client</artifactId>

<version>1.3.2</version>

</dependency>

</dependencies>

<build>

<finalName>test</finalName>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.3</version>

</plugin>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

</build>

</project>

这是我的Application.java

package app;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.ApplicationContext;

@SpringBootApplication

@EnableAdminServer

@EnableDiscoveryClient

public class Application {

public static void main(String[] args) {

ApplicationContext ctx = SpringApplication.run(Application.class, args);

}

}

而我的application.yml文件:

info:

version: @pom.version@

stage: test

spring:

application:

name: @pom.artifactId@

boot:

admin:

url: http://localhost:8080

其余的我都很困惑。

  1. 那么我可以将我的应用程序注册为服务器和客户端吗?
  2. 如何运行此应用程序并访问管理页面?他们没有提及任何URL去查看管理页面。只是http://localhost:8080吗?
  3. 我该如何进行开发设置却在生产中将其关闭?底部的参考指南说:

我可以在我的业务应用程序中包含spring-boot-admin吗?

tl; dr可以,但是不可以。您可以设置spring.boot.admin.context-path来更改提供UI和REST-

api的路径,但是根据应用程序的复杂性,您可能会遇到麻烦。另一方面,我认为应用程序无法自我监控。万一您的应用程序出现故障,您的监控工具也会这样做。

我的意思是说您不应该在生产中使用它。因此,如果您不能使用spring boot

admin来监视生产中的应用程序,那有什么意义呢?解决方案是否具有2个应用程序,一个是您的业务应用程序,另一个是您的监视业务应用程序的监视应用程序?

回答:

  1. 那么我可以将我的应用程序注册为服务器和客户端吗?

在您的示例中,您这样做。管理服务器本身就是客户端,这不是问题。实际上,spring-boot-admin-

sample是通过这种方式配置的,因此您可以获得有关管理服务器本身的信息。

  1. 如何运行此应用程序并访问管理页面?他们没有提及任何URL去查看管理页面。只是: http://

    localhost:8080吗?

是。如果您未设置,spring.boot.admin.context-

path则管理员以root身份提供。因此,如果您在业务应用程序内部附带管理员,则应进行配置,spring.boot.admin.context-

path以便将其提供给其他地方。

  1. 我该如何进行开发设置却在生产中将其关闭?底部的参考指南说:…

关键是要使用两个单独的应用程序。这是我们从开发阶段,质量保证阶段到生产阶段的方法。我们总是将业务与管理服务器分开。如果要有条件地在业务应用程序中启用管理服务器,请尝试以下方法:编写@Configuration-class

wich仅在特定配置文件中处于活动状态,然后将其移动@EnableAdminServer到此配置。

希望这可以帮助。

以上是 Spring Boot管理员页面 的全部内容, 来源链接: utcz.com/qa/404120.html

回到顶部