We have this constant discussion in our project as to the granularity of our maven modules. We have come to agree that there may be differences in the needs of a framework (like spring) and an in-house application that is always deployed monolithically.
我们在项目中不断讨论我们的maven模块的粒度。我们已经同意框架(如spring)和内部应用程序(需要整体部署)的需求可能存在差异。
We also agree that it's fairly sensible to hide implementation details of adapters to external systems behind a separate API module, so the implementation classes don't bleed into the classpath of the main implementations. as But that's as far as we go. It's a web project so we have modules like "web", "core" and "adapter(s)". We have multiple backends, but we don't require plugability.
我们也同意将适配器的实现细节隐藏到单独的API模块后面的外部系统是相当明智的,因此实现类不会渗透到主要实现的类路径中。因为那就是我们走的路。这是一个Web项目,所以我们有“web”,“core”和“adapter(s)”等模块。我们有多个后端,但我们不需要可插拔性。
What criteria do you use for modularizing in maven ? Which modules do you make for web projects ?
您在maven模块化中使用什么标准?您为Web项目制作了哪些模块?
1 个解决方案
#1
4
In my opinion, the project division should be pretty fine grained, even for "only a webapp".
在我看来,项目部门应该非常精细,即使对于“只有一个webapp”。
I would make separate projects for the data access layer interfaces and implementation, business layer interfaces and implementation, and the webapp itself. I would also make atleast one "commons" project for containing code relevant to more than one of the other projects. But this is just the beginning. I would not hesitate to extract a commons-util project for utility classes relevant regardless of the application that is being developed (String, Date, Reflection, etc). I would also make a project for useful utilities when doing testing (commons-test). And that's just the next step ... ;)
我将为数据访问层接口和实现,业务层接口和实现以及webapp本身制作单独的项目。我还要制作至少一个“公共”项目,用于包含与多个其他项目相关的代码。但这只是一个开始。我会毫不犹豫地为与实用程序类相关的commons-util项目提取,而不管正在开发的应用程序(字符串,日期,反射等)。我还会在进行测试(公共测试)时为有用的实用程序创建一个项目。这只是下一步...;)
If I wrote generally useful code relevant to hibernate, I would put it in a hibernate-utils project. Useful Spring utilities would go in a spring-utils project etc. When doing this, many projects will only contain a single or a few packages, and the packages will commonly contain few classes.
如果我编写了与hibernate相关的一般有用的代码,我会把它放在一个hibernate-utils项目中。有用的Spring实用程序将进入spring-utils项目等。执行此操作时,许多项目将只包含一个或几个包,并且包通常包含很少的类。
My reasoning for doing this, is that it helps me think about the code I write. Is this REALLY business logic, or is it general String manipulation, Date manipulation, Hibernate specific logic etc? My layers become cleaner, and it becomes harder to get circular dependencies between packages and projects (we don't want those). In addition, it becomes much easier to reuse code in other projects. There will always be other projects...
我这样做的理由是,它可以帮助我思考我编写的代码。这是真正的业务逻辑,还是一般的字符串操作,日期操作,Hibernate特定的逻辑等?我的图层变得更清晰,在包和项目之间获得循环依赖变得更加困难(我们不希望这些)。此外,在其他项目中重用代码变得更加容易。总会有其他项目......
I have also found that it is easier for new developers to get a hang of the structure, because the projects become smaller and more manageable; it's easier to start coding when you feel you don't have to under stand everything.
我还发现新开发人员更容易掌握结构,因为项目变得更小,更易于管理;当你觉得自己不必放下一切时,开始编码会更容易。
As a last advantage to the fine grained approach, build times reduce because you don't have to build everything every time.
作为细粒度方法的最后一个优点,构建时间减少,因为您不必每次都构建所有内容。
#1
4
In my opinion, the project division should be pretty fine grained, even for "only a webapp".
在我看来,项目部门应该非常精细,即使对于“只有一个webapp”。
I would make separate projects for the data access layer interfaces and implementation, business layer interfaces and implementation, and the webapp itself. I would also make atleast one "commons" project for containing code relevant to more than one of the other projects. But this is just the beginning. I would not hesitate to extract a commons-util project for utility classes relevant regardless of the application that is being developed (String, Date, Reflection, etc). I would also make a project for useful utilities when doing testing (commons-test). And that's just the next step ... ;)
我将为数据访问层接口和实现,业务层接口和实现以及webapp本身制作单独的项目。我还要制作至少一个“公共”项目,用于包含与多个其他项目相关的代码。但这只是一个开始。我会毫不犹豫地为与实用程序类相关的commons-util项目提取,而不管正在开发的应用程序(字符串,日期,反射等)。我还会在进行测试(公共测试)时为有用的实用程序创建一个项目。这只是下一步...;)
If I wrote generally useful code relevant to hibernate, I would put it in a hibernate-utils project. Useful Spring utilities would go in a spring-utils project etc. When doing this, many projects will only contain a single or a few packages, and the packages will commonly contain few classes.
如果我编写了与hibernate相关的一般有用的代码,我会把它放在一个hibernate-utils项目中。有用的Spring实用程序将进入spring-utils项目等。执行此操作时,许多项目将只包含一个或几个包,并且包通常包含很少的类。
My reasoning for doing this, is that it helps me think about the code I write. Is this REALLY business logic, or is it general String manipulation, Date manipulation, Hibernate specific logic etc? My layers become cleaner, and it becomes harder to get circular dependencies between packages and projects (we don't want those). In addition, it becomes much easier to reuse code in other projects. There will always be other projects...
我这样做的理由是,它可以帮助我思考我编写的代码。这是真正的业务逻辑,还是一般的字符串操作,日期操作,Hibernate特定的逻辑等?我的图层变得更清晰,在包和项目之间获得循环依赖变得更加困难(我们不希望这些)。此外,在其他项目中重用代码变得更加容易。总会有其他项目......
I have also found that it is easier for new developers to get a hang of the structure, because the projects become smaller and more manageable; it's easier to start coding when you feel you don't have to under stand everything.
我还发现新开发人员更容易掌握结构,因为项目变得更小,更易于管理;当你觉得自己不必放下一切时,开始编码会更容易。
As a last advantage to the fine grained approach, build times reduce because you don't have to build everything every time.
作为细粒度方法的最后一个优点,构建时间减少,因为您不必每次都构建所有内容。