Netty is a set of asynchronous, event-driven, network application frameworks that are also toolkits. We can use it as the core framework of the project, but also with some of the features he provides to support the project, so the modularity of the project function is very important, which is what we usually pursue the reusability of the project.
Netty a project as a whole is organized as follows:
。
This does not say the function of the various sub-modules of the project, just see how to achieve the separation and organization of the project module.
There may be a structure like this in our usual development:
If it is a small project to do this is also good, at least to achieve a relatively low level of "high cohesion, lower coupling." But if there are 10 of such small projects, each will use the Util package, then it will be more sad, just each project to synchronize the state of Util will consume a lot of energy.
It's a lot more graceful to manage with Maven's modularity:
Consider the composition of the project:
The first tiegr-parent project is our real master project, which contains 3 sub-modules: Tiger-all,tiger-modules1 and Tiger-util 3 submodules. Each module can be developed and managed as a separate project. and the most direct manifestation of this is the improvement of reusability and the decrease of coupling between modules. Dependencies between projects are fully managed by a configuration file.
Here are the dependencies and configurations of the simulated projects:
<!--tiger-parent/pom.xml --<?xml version= "1.0" encoding= "UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/POM/ 4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <modelversion>4.0.0</modelversion> <groupId>Com.tiger</groupId> <artifactid>App-parent</artifactid> <packaging>Pom</Packaging> <version>1.0</version> <modules> <module>Tiger-modules1</module> <module>Tiger-util</module> <module>Tiger-all</module> </Modules> </Project>
<!--tiger-modules1/pom.xml --<?xml version= "1.0" encoding= "UTF-8"?><project xsi:schemalocation="http://maven.apache.org/POM/4.0.0/HTTP// Maven.apache.org/xsd/maven-4.0.0.xsd " xmlns=" http://maven.apache.org/POM/4.0.0 "xmlns : xsi="Http://www.w3.org/2001/XMLSchema-instance"> <modelversion>4.0.0</modelversion> <parent> <groupId>Com.tiger</groupId> <artifactid>App-parent</artifactid> <version>1.0</version> </Parent> <artifactid>Tiger-modules1</artifactid> <packaging>Jar</Packaging> <name>Tiger-modules1</name> <dependencies> <dependency> <groupId>${project.groupid}</groupId> <artifactid>Tiger-util</artifactid> <version>${project.version}</version> </Dependency> </dependencies></Project>
<!--tiger-util/pom.xml --<?xml version= "1.0"?><project xsi:schemalocation="http://maven.apache.org/POM/4.0.0/HTTP// Maven.apache.org/xsd/maven-4.0.0.xsd " xmlns=" http://maven.apache.org/POM/4.0.0 " xmlns:xsi="Http://www.w3.org/2001/XMLSchema-instance"> <modelversion>4.0.0</modelversion> <parent> <groupId>Com.tiger</groupId> <artifactid>App-parent</artifactid> <version>1.0</version> </Parent> <artifactid>Tiger-util</artifactid> <packaging>Jar</Packaging> <name>Tiger-util</name> <URL>http://maven.apache.org</URL> <dependencies> <!--JUnit Testing Framework -- <dependency> <groupId>Junit</groupId> <artifactid>Junit</artifactid> <version>4.10</version> <scope>Test</Scope> </Dependency> </dependencies></Project>
From here we see that our projects are managed through dependencies, and each module or function is introduced as a separate project. Not only are the relationships clear, but you can also maximize the "slimming" of each module.
Code all this management suddenly feel the whole mood is a lot better, there is no ~ ^_^
Modules module configuration from Netty Project organization starter MAVEN