Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在为项目定义自己的例外时,maven 项目结构或包命名约定中是否有特定位置?我认为将它们放入“异常”包中会很好,但我想我会在这里问,因为 googlebox 没有产生任何答案。
这个问题与maven无关。基本上,您是在询问应将异常放置在包层次结构中的哪个位置。
由于异常与任何其他类一样,因此建议是相同的:靠近使用它们的位置(最好是相同的包)。
Tomasz 所说的,但如果有很多例外,请将它们放在自己的包中 - 通常称为com.mycompany.<topic>.exceptions
com.mycompany.<topic>.exceptions
不,Maven 不知道 Java 包是如何组织的。