maven builds a multi-pom project (module)

 

 

demo downloadhttp  ://download.csdn.net/download/knight_black_bob/9796647

 

 

Project construction

 

 

1. Get svn

http://127.0.0.1/opp/project/code/trunk/aaa

 

 

2. Create a new svn project directory

 Create directories such as code doc



 

 

After completion, the svn directory structure is (below), we code in trunk , branch in branches, and version in tag



 

 

3. Create a new multi- pom structure project

3.1 New pom total project project

Right click -> new -> other



 

 

Select maven project -> next ->



 

Select maven-archetype-quickstart to quickly build a maven project -> next



 Fill
in the groundid , artifacttId and other information -> Finish

 



 

 

After the successful creation of the project directory (as shown in the figure)



 

 

 

3.2 Overall pom engineering structure arrangement

3.2.1 Delete

All src/main/java , src/main/resources and other file structures, only keep the pom.xml folder



 

3.2.1 Modify the total project pom file

Modify packaging to pom   so that Module can be added .

After the modification, it is found that the project has a red cross , you can choose to right-click the project -> maven -> update project , the red cross disappears



 

 

3.3 New Module 

3.3.1 New Module com.project.entity 

Right click on the project -> new -> other

 

 

 

 

Select   Maven Module


 
 

Create a new module, fill in the groundid , artifacttId and other information -> Finish

 

 

 

 

project directory after completion



 

 

In the same way, create new modules such as service serviceImpl rest web

3.3.2 New Module   com.project .service   

 

3.3.3 New Module   com.project .serviceImpl  

 

3.3.4 New Module   com.project .rest

 

3.3.5 New Module  com.project .web

 

3.3.6 Configure each module file

3.3.6.0 View project directory



 

 

3.3.6.1 View the pom under the general project



 

 

Every time a new module is created , modules are added to the pom of the total project , which is automatic

 

3.3.6.2 View the pom dependencies in each module




 
 

 

<parent>

    <groupId>com.project.aaa</groupId>

    <artifactId>project</artifactId>

    <version>0.0.1-SNAPSHOT</version>

  </parent>

 

The dependency is the directory of the general project . This is to depend on the parent project's dependency center.

 

 

3.3.6.2 Delete automatically generated classes in all modules



 

3.3.6.3 Delete unit test dependencies in all modules



 

 

3.3.6.4 Add packaging to each module

 

 

 

 

Where entity, service, serviceImpl  are <packaging>jar</packaging>  

Rest,  web <packaging>war</packaging>

 

3.3.6.5 Converting a web module into a web project

Right click module -> properties



 

Select project facets -> select java  version -> select Dynamic Web Module -> select Furher Config



 

 

Modify content directory

 

 

 

 

 

3.3.6.6 Add java plugin dependency

The current web project reports a red cross , the problems show that the java version is too low, must 1.6 or later

<plugin>

              <!-- JDK version used by MAVEN compilation -->

              <groupId>org.apache.maven.plugins</groupId>

              <artifactId>maven-compiler-plugin</artifactId>

              <version>3.3</version>

              <configuration>

                  <source>1.7</source>

                  <target>1.7</target>

              </configuration>

           </plugin>

 

We add the plugin to the parent project , then right-click the parent project, select maven , select update project , the red cross disappears.


 
 

 

 

 

 

 

3.3.7 Testing

In summary , the project structure is completed , let's try to run the maven command

source:jar install -Dmaven.test.skip=true –X

show success



 

 

 

The local repository already contains the packaged jar



 

4. Project Architecture

 

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Donate to developers

Driven by interest, I write 免费something with joy and sweat. I hope you like my work and can support it at the same time. Of course, if you have money to support a money field (the love sign in the upper right corner, support Alipay and PayPal donations), if you have no money to support a personal field, thank you.



 
 
 Thank you for your sponsorship, I will do better!

 

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326394777&siteId=291194637