Maven + Eclipse + Tomcat-Start Project Commissioning Tour (reprint)

Source: Internet
Author: User
Tags custom name

Readers of this article need to have some MAVEN basics and practices, and if not, go straight around or read some of the MAVEN's authoritative guides on Maven tutorials, such as Juven translations, and Google will know.

To get straight to the point, first throw a question (if you are not interested in the problem I encountered, please drift over, directly see the line below the text):

I have a team infrastructure project, code name: framework, built with Maven, is a war type project. It is used by other applications in the team, including Java programs and web-related files (common components such as JS, CSS, and HTML). So I produced multiple builds in the package, including: The jar file containing the Java program (classifier to bin) and the zip file containing the Web common components (classifier is webcontent), and posted to SVN. Because there are a lot of projects that are built with pure eclipse and eclipse+maven, I think this is the most balanced way to package the framework.

In one of the applications I'm responsible for (this project is built with Eclipse+maven, which is called He applies project a), the framework project is included in the dependency of the Pom, and classifier is set to bin. It is no problem to deploy the operation in a Maven-tomcat-plugin way, the framework-bin-< version number >.jar file is automatically added to the Web-inf/lib directory of the Application project A. However, it is not possible to stop at a breakpoint and debug when this command-line startup Maven-tomcat-plugin runs the project. Later, I could only attempt to launch the application project A with Tomcat set up in the eclipse environment, but I would report an error that some class definitions in the framework could not be found. In fact, this error will not occur if the framework project is a jar-type Maven project, because M2eclipse will automatically make the framework into a jar package and put it into the Web-inf/lib directory of application item A when it is released. This point m2eclipse do very well, no doubt about it. The problem, however, is that the framework exists as a Web project, that is, the type is a war. In this case, the inside of the jar package of the framework Project M2eclipse is actually the structure of the war package. In other words, the structure is completely Web project, including the Web-inf folder, the real need to use the Java program is also put into the web-inf/classes directory. Earlier we said that the classifier settings that were dependent on application project A's framework project were set up in order to bin, and in the framework project, a package configuration of classifier was added to the bin and deployed to the MAVEN private library. However, M2eclipse did not pay attention to classifier when it matched the Tomcat deployment of application project A in the eclipse environment. I suspect it is a m2eclipse inappropriate place, not my configuration problem.

-----------here is the split line-----------

The above is the problem I encountered, in the case of invalid n method, I think of the direct use of maven-tomcat-plugin to deploy, run and debug Application project A. Juven's "maven combat" may be introduced, but the book is not in the office, also inconvenient to view:). Find some information on the Internet, are very cumbersome. Finally saw an article abroad: Http://docs.codehaus.org/display/MAVENUSER/Dealing+with+Eclipse-based+IDE. Before the 2.0.8 version of MAVEN, debugging MAVEN projects in a ECLIPSE+TOMCAT environment does require a lot of configuration, but it's much easier after the 2.0.8 version. The following are the specific methods:

1. After installing the M2eclipse plugin and configuring Maven-tomcat-plugin, click "Run Configurations" in the Eclipse Menu "Run".

2. In the left tree of the popup dialog box, look for "to Maven Build", right click on it and click "New".

3. Enter a custom name in the "name" column on the right. Click on the "Browse Workspace" button on the "Main" tab, select the target item, and in the "Base directory" column you will see the contents of the shape "${workspace_loc:/project_a}" (Project_ A is the application item A, as described above, and it will change depending on the target item you selected).

4. Enter "Tomcat:run" in the "Goals" column.

5. In the MAVEN Runtime select the MAVEN environment you need (note: Must be 2.0.8 or higher).

6. Click "Apply" to complete the configuration.

After testing, through the above configuration, the "name" value in your previous configuration will be found under Eclipse's own run ("Right Arrow") and the Debug ("Bug") button ("M2" is also identified in the front end of the entry). Click to start a run or debug operation on the appropriate project based on Tomcat. Whether you are running a project or debugging a project depends only on whether the entry you clicked is under the right arrow button or under the Bug button. From this point of view, they are still very intelligent.

In fact, the above configuration is not complicated, I believe that the reader to follow the above steps to do is completely can be done. The problem before dividing the line is that we want to raise some thoughts about software usability and compatibility. Hope that the two points interested in the replies of friends to discuss.

This article is from "Hyper Mind" blog, please make sure to keep this source http://freej.blog.51cto.com/235241/449339

Maven + Eclipse + Tomcat-Start Project Commissioning Tour (reprint)

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.