Maven + eclipse + Tomcat-start the project debugging journey

Source: Internet
Author: User
Tags custom name

Readers of this article need to have some basic Maven knowledge and practices. If you do not have any, Please bypass or take a look at some Maven tutorials, such as the maven authoritative guide translated by juven.

When you get started, you should first throw a question (if you are not interested in my problem, please see the text below the split line ):

I have a basic team framework project, code: Framework, built with Maven. It is a war-type project. Other application projects in the team will use it, including Java programs and some web-related files (JS, CSS, HTML, and other public components ). Therefore, I generated multiple builds during package, including: jar files containing Java programs (whose classifier is Bin) and ZIP files containing web public components (whose classifier is webcontent, and released to SVN. Because there are not a few projects built using pure eclipse and eclipse + Maven, I think it is the most balanced way to package and release the framework.

In an application project I am in charge of (this project is built using eclipse + Maven and is called Application Project A for the time being), the POM dependency includes this framework project, set classifier to bin. It is okay to deploy and run with Maven-Tomcat-plugin, and the framework-bin-<version number> will be automatically added to the WEB-INF/lib directory of Application Project. JAR file, but in this case, when you start Maven-Tomcat-plugin to run the project using the command line, you cannot stop at the breakpoint and debug it. Then, I can only try to start Application Project A with Tomcat set in the eclipse environment, but an error will be reported that some class definitions in the framework cannot be found. In fact, this error will not occur if the framework project is a Maven project of the jar type, because m2eclipse will automatically compress the framework into a jar package and put it in the WEB-INF/lib directory of Application Project A at the time of release. M2eclipse is doing very well and there is no doubt. However, the problem is that the framework exists in the form of a web project, that is, the type is war. In this case, the jar package of the Framework project of m2eclipse is actually the structure of the war package. That is to say, the structure is completely web project, contains the folder such as WEB-INF, the Java program that really needs to be used is also put into the WEB-INF/classes directory. As mentioned above, we set the classifier of the Framework project of Application Project A to bin. In the Framework project, we also add the package configuration of classifier as bin and deploy it to the maven private library. However, m2eclipse does not pay attention to classifier when deploying tomcat in the eclipse environment with Application Project. I suspect that m2eclipse is inappropriate, not my configuration problems.

----------- Here is the split line -----------

The above are my problems. When n methods are invalid, I thought of using Maven-Tomcat-plugin directly to deploy, run, and debug application project. Juven's MAVEN practice may be introduced, but the book is not in the office and cannot be viewed :). I found some information on the Internet, which is complicated. Finally, I saw a foreign Article: http://docs.codehaus.org/display/mavenuser/dealing?with=#se-based=ide. We can see that many configurations are required to debug the maven project in the eclipse + Tomcat environment before version 2.0.8 of Maven, but it is much easier after version 2.0.8. The procedure is as follows:

1. After installing the m2eclipse plug-in and configuring Maven-Tomcat-plugin, click "Run deployments" in "run" of Eclipse ".

2. In the pop-up dialog box, find "go to Maven build" in the left Tree, right-click it, and click "new ".

3. Enter the custom name in the "name" field on the right. Click the "Browse workspace" button on the "Main" tab, select the target project, and click "$ {workspace_loc: "/project_a}" (project_a is the project A, which will change according to the project you selected ).

4. Fill in "Tomcat: Run" in the "goals" column ".

5. Select the maven environment you need in "Maven RunTime" (Note: The version must be 2.0.8 or later ).

6. Click Apply to complete the configuration.

After testing, through the above configuration, run ("right arrow") and debug ("little bug") in eclipse itself ") the button will find the entry named "name" in your previous configuration (the front-end of the entry will also have the "m2" identifier ), click it to start the running or debugging operations of the corresponding project based on Tomcat. To run the project or debug the project, it only depends on whether the item you clicked is under the "right arrow" button or under the "bug" button. From this perspective, they are still very intelligent.

In fact, the above configuration is not complex. I believe that the reader can do it according to the above steps. Before the split line, I want to raise some questions about the ease of use and compatibility of the software. I hope you will reply to these two questions.

This article is from the hyper mind blog, be sure to keep this source http://freej.blog.51cto.com/235241/449339

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.