在小型应用程序中使用Maven Multimodule有什么好处吗? [英] Is there any benefit in using Maven Multimodule when working in a small application?

查看:99
本文介绍了在小型应用程序中使用Maven Multimodule有什么好处吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用不同的架构层构建一个小型应用程序,例如域,接口,基础架构和应用程序。这遵循洋葱DDD模型。现在我想知道将应用程序拆分为多模块maven项目是否有任何好处。据我所知,现在似乎使事情变得比需要的更困难。整个应用程序将作为单个WAR文件部署到Tomcat容器中。

We are building a small application using different architectural layers such as domain, interface, infrastructure and application. This follows the Onion DDD model. Now I am wondering if there is any benefit in splitting the application into a multimodule maven project. As far as I can see now it seems to make things more difficult than needed. The entire application will be deployed as a single WAR file into a Tomcat container.

推荐答案

拆分应用程序对以下内容有意义:

Splitting your application makes sense for the following:


  • 当项目的某个部分需要新功能或错误修复时,您可以只关注该模块并运行只是测试它。编译所有代码的一小部分并运行相关测试可加快您的工作。

  • When a certain part of the project needs to have new functionality or bug fixes, you can simply focus on that module and run just the tests for it. Compiling a fraction of all the code and running just the related tests speeds up your work.

您可以在不同项目中重用模块中的代码。假设您的项目包含一些编写良好的通用足够的邮件发送代码。如果您以后有另一个需要邮件发送功能的项目,您只需重新使用现有模块或在其上构建(在另一个模块中将其添加为依赖项)。

You can re-use the code from the modules across different projects. Let's assume your project contains some well-written generic-enough code for mail sending. If you later have another project that need mail sending functionality, you can simply re-use your existing module or build upon it (in another module by adding it as a dependency).

从长远来看,易于维护。也许现在它似乎是一个小项目。在几个月内,事情可能会有所不同,然后你需要做更多的重构,将事物分成逻辑单元(模块)。

Easier maintainability on the long run. Maybe now it seems like a small project. In a few months things might look different and then you'll need to do more refactoring to split things into logical units (modules).

概念清晰度(如由Adriaan Koster添加。

Conceptual clarity (as added by Adriaan Koster).

关于WAR:您可以拥有一个组装模块,将组合在一起并生成来自所有相关模块的最终WAR文件。

Concerning the WAR: You can have an assembly module which puts things together and produces a final WAR file from all the related modules.

最初,这可能看起来更多,但从长远来看,模块化项目更容易使用和维护。大多数理智的开发人员更喜欢这种方法。

Initially, this may seem as more work, but in the long-run, modularized projects are easier to work with and to maintain. Most sane developers would prefer this approach.

这篇关于在小型应用程序中使用Maven Multimodule有什么好处吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆