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

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

问题描述

我们正在使用不同的架构层(例如域、接口、基础设施和应用程序)构建一个小型应用程序.这遵循 Onion 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天全站免登陆