繁体   English   中英

是什么导致了这个 ArchUnit 异常?

[英]What causes this ArchUnit exception?

谢谢你的时间,

我一直在试验 Archunit,但我无法解决这个问题:

ComponentIntersectionException: Class 
com.yyy.xxx.common.configurations.properties.SomeClass may not be contained in more 
than one component, but is contained in [Common, Configuration]

我有一个相当标准的植物图; 虽然我不想分享它,但我可能遗漏了 ArchUnit 的一些细微差别。 我的问题是,具体而言,在高层次上我必须做错什么?

附加信息:测试:

    @Test
    void diagram_layersShouldBeRespected() throws IOException {
        classes().should(adhereToPlantUmlDiagram(PLANTUML_YAMl, consideringOnlyDependenciesInDiagram())).check(ALL_PROJECT_CLASSES);
    }

亚姆:

@startuml
 
package "Config" {
  [Configuration] <<..configurations.properties..>>
//this is where SomeClass resides
}
 
package "Web Layer" {
  [Controller] <<..web.controllers..>>
  [Resources] <<..web.resources..>>
}
 
package "Business Layer" {
  [Services] <<..services..>>
  [Business Model] <<..models..>>
}
 
package "Adapter Layer" {
  [Databases] <<..dataaccess..>>
  [Integration] <<..adapters.azure..>> 
  [Storage] <<..adapters.azure.storage..>> 
}
 
package "Common Layer" {
  [Common] <<..common..>>
}
 
[Configuration] --> [Services]
[Configuration] --> [Storage]
[Configuration] --> [Common]
[Configuration] --> [Configuration]
[Common] --> [Configuration]
 
[Controller] --> [Resources]
[Controller] --> [Services]
[Controller] --> [Common]
[Resources] --> [Common]
 
[Services] --> [Databases]
[Services] --> [Integration]
[Services] --> [Storage]
[Services] --> [Common]
 
[Databases] --> [Common]
[Integration] --> [Common]
[Storage] --> [Common]
 
@enduml

当@Thomas 让我思考问题的根源时,我已经解决了它,如下所示:

问题是作为组件(A)描述的一部分的包太模糊了,以至于另一个组件(B)的描述也可以被认为是该组件(A),所以我的一些类是被认为属于 >=2 个组件。

暂无
暂无

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

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