MAVEN multi-module Project Eclipse Thermal deployment Maven project implementation Tomcat Hot deployment

Source: Internet
Author: User
Tags java web tomcat server

The MAVEN multi-module project is hot-deployed under Eclipse, where you can experience the code for any module in the entire project, without the need for MAVEN packaging to see the effect,

1, first ready to create a MAVEN multi-project code, ready an eclipse, a tomcat, what Java environment, Tomcat environment I will not say, if you do not have the right to look down,

2, create the project, MVN archetype:generate-dgroupid=com.laoshuisheng-dartifactid=test-dversion=1.0

After the success of the creation of the Pom.xml file to modify the Pom.xml

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.laoshuisheng</groupId> <artifactId> test</artifactid> <version>1.0</version> <packaging>jar</packaging> <name> Test</name> <url>http://maven.apache.org</url> <properties> < Project.build.sourceencoding>utf-8</project.build.sourceencoding> </properties> <dependencies > <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> < version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </ Project>

Modified to below

Oject 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.laoshuisheng</groupId> <artifactId> test</artifactid> <version>1.0</version> <packaging>pom</packaging> <name> Test</name> <url>http://maven.apache.org</url> <properties> < Project.build.sourceencoding>utf-8</project.build.sourceencoding> </properties> <dependencies > <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> < version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </ Project>

Enter the project inside casually create a few modules, I here to facilitate the creation of only two modules well, one is the Web project, one is the business code

.../test>mvn Archetype:generate-dgroupid=com.laoshuisheng.web-dartifactid=test-web-darchetypearti
factid=maven-archetype-webapp-dversion=1.0

To create a business code project:

.. /TEST>MVN Archetype:generate-dgroupid=com.laoshuisheng.web-dartifactid=test-core-darchetypeart
ifactid=maven-archetype-quickstart-dversion=1.0

Finished creating the following figure:

All right, now that the project was created, we're going to import eclipse, and that's important, and you have to look at it carefully, and the imported commands are:

... test>mvn eclipse:eclipse-dwtpversion=1.0

Remember that Eclipse recognizes it as a Web project rather than a simple Java project, and you should know that Web projects can do something else in eclipse.-dwtpversion=1.0

Remember, it's a generic import, not a MAVEN project import.

See, there's a little Earth on the project that says Eclipse recognized him as a Java Web project, and yes, that would give us unexpected results.

Next, we're going to add dependencies on the project, adding to the Test-core in the pom.xml of the Web project:

<?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> <artifactid>test </artifactId> <groupId>com.laoshuisheng</groupId> <version>1.0</version> </ Parent> <groupId>com.laoshuisheng.web</groupId> <artifactId>test-web</artifactId> < version>1.0</version> <packaging>war</packaging> <name>test-web Maven webapp</name > <url>http://maven.apache.org</url> <dependencies> <dependency> <groupid>junit </groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope> test</scope> </dependency> <dependency> <groupId>com.laoshuisheng.web</groupId> < Artifactid>test-core</artifactid> <version>1.0</version> </dependency> </dependencies> <build> <finalName>test-web</finalName> </build> </project>

Plus after mvn eclipse:clean eclipse:eclipse refresh under Eclipse's Project discovery:

This is the time to configure to the server, because although the MAVEN project, but we developed the server is running under the Web under the Classes class file and

WebApp the following files, such as JSP/CSS/JS, so do not need to pack anything, if it is dependent such as Test-core is run classes compiled code, so do not need to compile, but here is a problem is that the configuration file must be placed under the classpath, Because I have just said the reason, the nonsense does not say much, look is the server,

This is what we create a good Tomcat server, and then everyone click on the right button, remember to point right on the server Oh, pop-up dialog box, good is the pop-up dialog box, which has an add and remove options, you will find a test-web

See it, know why I must emphasize the import project when add-dwtpversion=1.0, so that he can add here, eclipse recognized it is a Web project, haha, here basically has been successful, to see the effect of the addition:

Yes, it's good to see that the dependent modules are also successfully loaded, well, now you can arbitrarily modify the code inside these two pieces, do not need to repackage, do not need to restart the server, because we are using the thermal compilation of Eclipse to achieve, Or we don't need the ability to use MAVEN in development.

All right. Here Maven's multi-module project thermal compilation can be completely without any plug-ins to achieve, if you have anything do not understand directly to ask me, thank you.

Remember to write the place oh ....


Related Article

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.