MAVEN-based Web projects using Tomcat debugging in Eclipse

Source: Internet
Author: User

Previously developed used jetty to debug Maven project, but then also a bit of a muddle, is to use, spare time to dedicate to the game. When you're tinkering with Maven recently, take a look at the recent process of building eclipse to debug Maven projects with Tomcat, and later forget or have problems in between.

Needless to say, the following begins to build:

1. Install maven (Maven plugin in configure MAVEN environment variable +eclipse)

This step is not much to say, online a search a lot, to illustrate only a little, the first time with the MAVEN plug-in, be sure to update the index of the remote library, so add dependencies will not be found in the case of the jar package (of course, you must first enable the Remote Library index, or can not search the jar package)

2. Create a new MAVEN project, configure

After the MAVEN project is created, the properties->project facets-> "Convert to faceted form ...", tick the following 2 items in the Project facet that appears, and note that the subsequent version is selected:

Select OK, at the Times Open Project---Properties, you can see a deployment assembly option, open can see here is the corresponding relationship between the folder and the publishing folder is configured

Since MAVEN packs the Web. xml file from the Src/main/webapp directory by default, we also need to manually create one of these files below.

3. Configuring the Server for debugging (APATHC Tomcat)

As shown, create a new Tomcat container in eclipse:

3. Run the MAVEN project

After the above configuration, is it possible to run our Maven project?? Of course.

You can run our MAVEN project after selecting "Run on Server" as shown.

4. Remaining issues

(1), our browser input "http://localhost:8080/ssh2/index.html" return 404??

Don't worry, you can go to the workspace directory. Metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps see a folder with our MAVEN project name below, This is our debugging when the automatic publishing directory, you can see below and there is no page we added, God horse situation??

This is the publish directory where we did not configure Src/main/webapp, so we did not publish the following HTML and other content when debugging.

Solve:

Item, properties, Deployment Assembly, Add-a folder---Select Src/main/webapp

This step is to configure the WebApp directory to be published to the root of the project, and we'll see. metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ The SSH2 directory has an automatically published HTML file

Refresh the browser page, OK page out!!!

(2), is this OK?? The answer is in the negative.

Once we have added those dependent jars in the pom.xml, once they are applied in the code. When we debug locally, the ClassNotFound error is reported, why??

Because Tomcat does not understand these configurations, you must configure the jar in Maven dependencies with the Publish directory:

Project, properties, Deployment Assembly, Add, Java Build Path Entries, select Maven Dependencies, Finish-> ; Ok

This step is to configure the Maven dependency package publishing directory so that when debugging will automatically publish those jars to the specified directory, Tomcat can also find those jars.


MAVEN-based Web projects using Tomcat debugging in Eclipse

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.