MAVEN multi-module project, multi-Web merge Project Usage experience

Source: Internet
Author: User

Fixflow, be the best open source process engine in China ! Project Address Https://github.com/fixteam/fixflow

This article is suitable for MAVEN beginners or users who want to contact Maven, only to speak of fur, master please consciously skip.

Recently has been engaged in fixflow5.2 upgrade work, previously only know maven easy to use, but has never had the opportunity to contact, this time because of work needs, finally have time to see maven.

Since the previous project used LinkSource to manage the project structure, using Tomcat to debug, accustomed to, so although decided to use MAVEN, but still used to debug with Tomcat. So has been searching online maven Tomcat multi-web, found that are some of the articles reproduced, and all need this plugin, that plug-in, feel novice, but a few days to study down, I think the online program is not what I want, in fact, there is more simple, So here's a simple fixflow to use MAVEN to build a multi-web process.

About Fixflow's MAVEN structure introduction, you can refer to my other blog http://yang-ch.iteye.com/blog/2032905, which is the goal of this article.

In this article, I'm going to cover 3 parts:

    1. MAVEN multi-module project.
    2. MAVEN Multi-web merge project.
    3. MAVEN multi-Web merge projects are deployed and debugged in a eclipse+tomcat environment.
MAVEN Multi-Module project

The MAVEN multi-module project requires a parent project to aggregate the sub-modules, but in fact requires a parent pom.xml, the main function is to declare the submodule, the code is as follows:

XML code
  1. <modules>
  2. <module>modules/fixflow-core</module>
  3. <module>modules/fixflow-expand</module>
  4. <module>modules/fixflow-common-api</module>
  5. <module>modules/fixflow-common-servlet</module>
  6. <module>modules/fixflow-manage-servlet</module>
  7. <module>modules/fixflow-webapp-common</module>
  8. <module>modules/fixflow-webapp-taskcenter</module>
  9. <module>modules/fixflow-webapp-managecenter</module>
  10. <module>modules/fixflow-webapp-explorer</module>
  11. <module>modules/fixflow-converter</module>
  12. <module>modules/fixflow-webapp-editor</module>
  13. </Modules>

Then in the Submodule, declare the parent project, and the code in the Submodule is as follows:

XML code
  1. <parent>
  2. <groupId>com.founder.fix.fixflow</groupId>
  3. <artifactid>fixflow-root</artifactid>
  4. <version>5.0</version>
  5. <relativepath... /.. </relativepath>
  6. </Parent>

On the multi-module article, there are many online, but also very detailed, here no more say.

MAVEN Multi-Web merge project

Multi-Web project merger, mainly I found on the internet is not the material I ultimately want the effect, so here is the introduction of my final use of the program, there are many online solutions are introduced with Caro plug-ins, I do not understand why to use this plugin.

The overlays property of the MAVEN multi-web module Maven-war-plugin plugin is processed, and the final main Web project Pom.xml code is as follows

XML code
  1. <build>
  2. <finalname>bpmcenter</finalname>
  3. <plugins>
  4. <!--merge multiple Wars--
  5. <plugin>
  6. <groupId>org.apache.maven.plugins</groupId>
  7. <artifactid>maven-war-plugin</artifactid>
  8. <configuration>
  9. <packagingexcludes>web-inf/web.xml</packagingexcludes>
  10. <overlays>
  11. <overlay>
  12. <groupId>com.founder.fix.fixflow</groupId>
  13. <artifactid>fixflow-webapp-taskcenter</artifactid>
  14. </Overlay>
  15. </Overlays>
  16. </configuration>
  17. </plugin>
  18. </plugins>
  19. </Build>

Here to use the Maven-war-plugin, with the overlay attribute is enough to merge multiple Web, just use the process to pay attention to the following points:

  1. The merged child Web project Packaging property must be a war
  2. The merged child Web project must have dependencies added to the master project.
  3. In a merged subweb, if there is no web. XML, you will need to declare the code in Pom.xml
    1. <build>
    2. <finalname>fixflow-webapp-editor</finalname>
    3. <plugins>
    4. <plugin>
    5. <groupId>org.apache.maven.plugins</groupId>
    6. <artifactid>maven-war-plugin</artifactid>
    7. <configuration>
    8. <failonmissingwebxml>false</failonmissingwebxml>
    9. </configuration>
    10. </plugin>
    11. </plugins>
    12. </Build>

After doing this, the multi-Web project merge is basically done, and running MVN install will find that there are already other sub-modules in the war package.

Multi-Web projects deploy debugging in a ECLIPSE+TOMCAT environment

In Eclipse, it's much easier to use it, but the online version is too complicated for users who are used to the development of Tomcat.

For MAVEN projects, one environment to another environment should be only pom.xml files and src folder is enough, others are based on their own environment to do.

    1. Open Eclipse, modify the local MAVEN warehouse address, import the MAVEN project, and wait for the build to finish.
    2. Create server, open Window-prefrences-server-runtime environment-new .... Select the Tomcat path, JDK information, and this step is exactly the same as the original.
    3. Open the server view, new server, select the tomcat you just created, click Next, this step only needs to be added to the main Web project.
    4. Double-click the created server, select Publish Project to Tomcat's WebApps directory, click Pushlish, Finish.

Then go to the Tomcat directory and find that the merged web has been published to the corresponding directory. References to other Java projects have been packaged into a jar released to the LIB, but you can hit a breakpoint to try, can still debug, modify a piece of code, found that hot deployment is also possible, so that the original development habits are exactly the same.

Attentive users will find that, in fact, this is completely the same as our original construction, deployment, yes, MAVEN is not so complicated, m2eclipse maven plugin has helped us do a lot of things, Maven will only make the migration between our projects more convenient, more concise, That's one of the big reasons I like maven.

I am an absolute maven novice, the above article with only Maven's fur just, Maven more build function also need to go into the research, the above article just want to tell those who want to try Maven novice, in fact, maven not only to the code management brought great convenience, And we can not change our original development habits completely. So, embrace maven!

MAVEN multi-module project, multi-Web merge Project Usage experience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.