Maven learning tutorial: building a multi module enterprise project

First of all, I have learned how to install Maven and how to create Maven projects in the previous studies. Recently, I have finally made some progress and built an enterprise level multi module project.

Well, I won't say much nonsense. The details are as follows:

First, create a maven project, POM The XML file is as follows:

To build a multi module project, you must have a root directory with packaging as POM. After creating the Maven project, right-click the project -- > new

Enter your project name

The project creation is not repeated here. The created directory structure in eclipse is as follows:

Explain what these projects are for:

Easyframework model: data model, entity class corresponding to database table field

Easy framework core: core business project. It mainly deals with business logic

Easy framework persist: data persistence layer, which operates low-level databases.

Easyframework utils: tool classes. All tool classes are extracted and written in this project.

Easy framework Web: This is the web layer, page display and control layer of the whole project

Note: when creating these projects, only easyframework web is a web project, that is, Maven archetype webapp, and the rest are Java projects: Maven archetype QuickStart

Open the pom.exe of easyframework root XML file, you will see that the modularization is as follows:

The next step is to configure the dependencies of each module. I personally think the project is so dependent. I don't know if it's right, hehe

For example, the easyframework web project relies on three modules: easyframework core (business core), easyframework model (entity class) and easyframework utils (public tool class).

So how is it in the POM of easyframework web XML, as follows:

Open the Maven dependency of the project, and you will find that you have already relied on these three projects

But you should feel strange. Why are there so many jar packages? They only refer to these three projects. Where do you get so many jar packages.

You'll find that I'll POM again In the XML file, there is a parent node that inherits the POM of the root node, which is Maven's project inheritance dependency. It will inherit some values from the parent POM. This is necessary to build a large system

In this way, you don't need to add the same dependency elements over and over again. Of course, if you have the same dependency in the child project, the value in the parent POM will be overwritten.

The dependencies of the parent POM are as follows:

Of course, this parent POM is just an example. You can add related dependencies according to your own configuration. Here is a warehouse that I think is the best to use:

http://mvnrepository.com/ I believe everyone on earth knows this! ha-ha.....

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>