【问题标题】:Spring boot admin add custom tabSpring Boot 管理员添加自定义选项卡
【发布时间】:2018-11-21 19:08:11
【问题描述】:

我希望按照http://codecentric.github.io/spring-boot-admin/2.1.1/#customizing-custom-views-instance 的文档向 Spring Boot 管理服务器添加一个自定义选项卡

但是文档和示例项目https://github.com/codecentric/spring-boot-admin/tree/2.1.1/spring-boot-admin-samples/spring-boot-admin-sample-custom-ui 似乎并不能帮助理解如何去做。

我通过阅读文档和示例的理解是 ui 是一个单独的模块。

我似乎缺少的部分是如何将它们捆绑在一起 ui 模块和 spring boot 管理服务器并为它们提供服务。

这是我迄今为止尝试过的:https://github.com/anandsunderraman/custom-spring-boot-admin/tree/master

【问题讨论】:

    标签: user-interface spring-boot-admin


    【解决方案1】:

    是否成功尝试在 Spring Boot Admin Server 中添加自定义选项卡。

    先决条件:

    • 必须安装 npm/node 并添加到 $PATH
    • 节点版本必须 > 8.0.0。
    • 如果没有,请从NodeSite 下载最新的节点
    • Spring Boot Admin 版本 2.1.1
    • 处于工作状态的管理员/客户。

    遵循这些步骤(生成-构建自定义 UI/在服务器中集成自定义 UI/在客户端实现端点):

    生成/构建自定义 UI:

    1. 在本地签出spring-boot-admin-custom-sample-ui。我以样例一为例
    2. cd <spring-boot-admin-custom-sample-ui-directory>
    3. 运行命令npm install
      • 以上命令将安装所有包。您可能会收到很少的警告(对于对等依赖项),因此请尝试通过手动安装(npm install package-name@version-number)对等依赖项来解决它们。这些是 npm 包依赖项。
    4. 在 Intellij 中导入项目并运行 maven install 命令。
      • 这将执行exec-maven-plugin 并创建一个target/dist 目录。如果出现任何错误,请尝试解决该问题。我遇到了一些错误,例如找不到节点版本问题/vue-template-compiler。
      • 如果出现 vue-template-compiler not found 错误,则执行npm install vue-template-compiler@2.5.16
      • 一旦 maven 安装完成,就应该生成新的自定义选项卡所需的 UI。现在这需要集成到 Admin Server 中。 Maven install 也会在本地 repo 上安装 spring-boot-admin-sample-custom-ui

    在管理服务器中集成客户 UI

    1. 只需在 application.properties 中添加新属性(为了注入新的 UI):

      spring.boot.admin.ui.cache.no-cache=true

      spring.boot.admin.ui.extension-resource-locations=file:spring-boot-admin-sample-custom-ui-directory-path/target/dist/

      spring.boot.admin.ui.cache-templates=false

    2. 在服务器 pom.xml 中添加 spring-boot-admin-sample-custom-ui 的依赖项。这是建立在第 4 步之上的。

    3. 启动管理服务器。

    在客户端实现端点:

    1. 添加以下端点:

      @Endpoint(id = "自定义") 公共类 CustomEndpoint { @ReadOperation 公共字符串 getHello(){ 返回“你好”; } }

      @豆 公共自定义端点 customEndpoint() { 返回新的自定义端点(); }

    2. 启动客户端。您应该在 Server 上看到如下内容:

    这完全是关于一个示例终点。您可以编写自己的视图并按照类似的步骤操作。视图必须作为 Vue.js 组件实现。

    希望这将简化在 spring boot admin 中添加新自定义选项卡的过程。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-16
      • 1970-01-01
      相关资源
      最近更新 更多