a multi-module maven project development

For a project (or a desktop project site), it will be roughly divided into three layers: the interface layer, a total user to see; the business logic layer, business logic; data access layer, CRUD database.

Depending on the size of the project, you can merge these three redevelopment together, these three can be separated from development. For large projects, usually separate development, not only to separate the levels, you can also arrange for developers to develop a certain level of difficulty. If you implement this hierarchical development, look at the steps of:

Note: Using development tools eclipse, server tomcat7

Step 1: Create the project, to create a site where the project as an example:

  

  Select the default skeleton

  

  Fill Group Id, Artifact Id, Version fill in any version, Packaging choose pom

  

       In this way, the project was created out

  

 

Step 2: Create project sub-module, according to the hierarchical project website (servlet interface layer, service logic layer, dao data access layer, entity javaBean, utils tools), respectively, to create a sub-module project site

  

  After selecting the default framework, fill in sub-module name, select the parent item and click Next

  

       Here we must note, depending on the nature of the sub-module, select the type of package, in general, desktop items are selected jar, and website project, in addition to the interface layer selection wer, the rest are selected jar packaging

  

  Turn all of the sub-modules created

  

 

The third step: to establish contact between the module module. A project that calls between the module and the module each method or class, so to establish dependencies:

  In my project, for example, service layer need to call the dao layer, entity javaBean, and may call utils Tools

       In the service module, open the file pom.xml

  

  Search for the corresponding sub-module project you want to add

  

  After completion of the classes and methods, service layer can call dao layer, entity javaBean, utils layer

 

Step 4: Add the external jar dependency, when a development project, the need to support the package from the outside jar, it is necessary to add an external package formation is dependent jar, add two ways jar outer package dependencies are:

  1. 全局添加,指多个子模块都会用到该外部jar依赖,比如说json jar包,

    开发总项目的pom.xml文件:

    

    搜索对应的jar包并添加,仓库没有以及不知道的可以网上搜索

  2. 局部添加 指仅仅只有一个模块会用的jar依赖

    打开需要添加jar依赖的模块中的pom.xml文件

    

    搜索对应的jar包并添加,仓库没有以及不知道的可以网上搜索

 

自此,一个项目分多模块就创建出来了

  

 

 

 

 

 

  

  

 

Guess you like

Origin www.cnblogs.com/hjlin/p/11298193.html