整体工程修改自 SBA 开源项目的 example 工程,具体使用 custom-ui 的工程链接为:[spring-boot-admin-sample-custom-ui]_,_红色框的部分是 arthas web console 的全部静态文件,通过 Maven Resource 的指定配置打入指定目录,实现 SBA 启动时的自定义加载。maven resource 配置–下:
<resource>
<directory>static</directory>
<targetPath>${project.build.directory}/classes/META-INF/spring-boot-admin-server-ui/extensions/arthas
</targetPath>
<filtering>false</filtering>
</resource>
最终构建的 jar 中 META-INFO 中包含相关的文件即可在 SBA 自带的 tomcat 启动后加载到相关的静态资源,最后的 url 和自定义实现的 arthas console 配置的外部 URL 对应即可。
SBA 2.0 开始已经使用 vue 全家桶了,扩展集成均比较方便。其中,官方文档给出了外嵌连接的配置方式:[Linking / Embedding External Pages]。
参考 sba example 工程的 application.yml 配置即可:
# tag::customization-external-views[]
spring:
boot:
admin:
ui:
external-views:
- label: "Arthas Console"
url: http://21.129.49.153:8080/
order: 1900
# end::customization-external-views[]
3. 对应 Spring MVC controller 实现
参考引用原实现的 SBA 集成部分,该部分主要修改实现如下功能:
-
实现 tunnel server 已经加载实例列表的刷新并展示到前段 AgentID 框供选择点击链接。
-
实现自定义 IP 地址的刷新(解决生产环境双生产 IP 和运维段 IP 不一致的问题)。