You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Structurizr系统景观视图配置多软件系统跳转链接?

Structurizr多软件系统景观视图跳转配置问题

我在Structurizr中创建系统景观视图展示所有软件系统关系,官方文档说明可配置工作区,让双击景观图里的软件系统A时跳转到它的详情工作区。但给多个软件系统实现该功能时遇到了问题:

  • 按官方建议每个软件系统单独创建继承全局景观工作区的workspace.dsl文件,生成的景观视图只有当前扩展的软件系统有跳转链接,其他系统无链接。
  • 若把所有工作区定义放在单个文件中,景观视图能显示多个跳转链接,但这与文档建议冲突,且执行inspect命令会报错,提示每个工作区文件只能定义一个软件系统。

想确认是否遗漏了某些DSL定义,或是官方建议的最佳实践与实际功能不匹配?


示例DSL文件

system-landscape.dsl

workspace {

    configuration {
        scope landscape
    }


    model {
        a = softwareSystem A
        b = softwareSystem B

        a -> b "request API" "https"
    }

    views {
        systemLandscape landscape {
            include *
            autolayout lr
        }
    }
}

软件系统A的workspace.dsl

workspace extends system-landscape.dsl {

    configuration {
        scope softwareSystem
    }

    model {
        !extend a {
            a-server = container "Server"
            a-db = container "Database"

            a-server -> a-db "read/write"
        }
    }

    views {
        systemContext a aSystemContextView {
            include *
            autolayout lr
        }

        container a aContainerView {
            include *
            autolayout lr
        }
    }
}

软件系统B的workspace.dsl

workspace extends system-landscape.dsl {

    configuration {
        scope softwareSystem
    }

    model {
        !extend b {
            b-server = container "Server"
            b-db = container "Database"

            b-server -> b-db "read/write"
        }
    }

    views {
        systemContext b bSystemContextView {
            include *
            autolayout lr
        }

        container b bContainerView {
            include *
            autolayout lr
        }
    }
}

解决方案

要实现多软件系统在景观视图中的跳转,需在全局景观工作区统一配置所有软件系统的跳转目标,同时保留每个软件系统独立工作区的模块化结构,具体步骤如下:

1. 修改全局景观工作区(system-landscape.dsl)

在configuration块中添加externalLinks配置,为每个软件系统指定对应的工作区路径:

workspace {

    configuration {
        scope landscape
        views {
            externalLinks {
                # 配置软件系统A的跳转目标
                element "a" {
                    url "./a-workspace.dsl" # 替换为A工作区的实际文件路径
                }
                # 配置软件系统B的跳转目标
                element "b" {
                    url "./b-workspace.dsl" # 替换为B工作区的实际文件路径
                }
            }
        }
    }

    model {
        a = softwareSystem A
        b = softwareSystem B

        a -> b "request API" "https"
    }

    views {
        systemLandscape landscape {
            include *
            autolayout lr
        }
    }
}

2. 保留独立软件系统工作区结构

每个软件系统的workspace.dsl继续继承全局景观工作区,仅扩展自身的容器和视图即可,无需额外配置跳转逻辑——跳转规则已在全局景观层统一定义。

3. 验证与构建

  • 执行structurizr validate检查DSL语法正确性
  • 使用structurizr export导出视图,此时景观视图中的A和B都会带有跳转链接,点击可跳转到各自的工作区详情
  • 运行inspect命令时,因每个工作区文件仅定义单个软件系统的扩展,不会再触发报错

关键说明

官方建议的“每个软件系统单独创建工作区”是为了保证模型的模块化和可维护性,而跳转功能需要在全局景观层统一配置所有元素的外部链接,这样既符合最佳实践,又能实现多系统跳转。之前的问题根源是跳转配置仅在单个软件系统的工作区中生效,全局景观未统一配置所有跳转目标。

内容的提问来源于stack exchange,提问作者SBH

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 15:40:09