MyEclipse + maven Developing a detailed configuration process for Web engineering

Source: Internet
Author: User

For a long time did not do web development, today suddenly want to get springmvc, because not long ago to learn a bit maven feel very good, so in SPRINGMVC this web framework want to use MAVEN to do, but the problem again, I have been in eclipse using Maven , and I used to do web development with MyEclipse (in Eclipse do web development personally think a little myeclipse convenient, in MyEclipse can directly use Tomcat debugging, is very convenient), So how to use both MyEclipse and Maven, today made a "tinkering", wrote this article.

Write it one step at a pace:

1. Creating a WebApp project with maven ----because it is generally necessary to follow a certain directory structure when using MAVEN, although you can also use a different directory structure. However, it is not yet familiar with how to modify the Pom.xml file to achieve the goal, and modifying too many default configurations is not good for maven.

To create a method, use the command in a directory: MVN Archetype:generate-darchetypeartifactid=maven-archetype-webapp. Follow the prompts to enter the appropriate parameters, the intermediate process is as follows:

C code
  1. D:\STUDY\WORKSPACE4>MVN Archetype:generate-darchetypeartifactid=maven-archetype-webapp
  2. [INFO] Scanning for projects ...
  3. ....
  4. [INFO] Generating project in Interactive mode
  5. Define value for property ' groupId ':: Com.xjd
  6. Define value for property ' Artifactid ':: MyWebApp
  7. Define value for property ' version ': 1.0-snapshot::
  8. Define value for property ' package ': Com.xjd::
  9. Confirm Properties Configuration:
  10. GroupId:com.xjd
  11. Artifactid:mywebapp
  12. Version:1.0-snapshot
  13. Package:com.xjd
  14. Y:: Y
  15. ....
  16. [INFO] BUILD SUCCESS
  17. [INFO]-----------------------------------------
  18. [INFO] Total time:1:46.199s
  19. [INFO] Finished at:wed Nov 15:02:18 CST 2011
  20. [INFO] Final memory:6m/15m

Finally, under the folder created a Maven WebApp project, the project's folder root directory "MyWebApp" (see the above procedure), the structure of the directory is

Java code
  1. MyWebApp
  2. +---Pom.xml
  3. +---SRC
  4. +---Main
  5. +---Resources
  6. +---WebApp
  7. +---index.jsp
  8. +---Web-inf
  9. +---web. xml

2. Activate the Maven plugin for configuration MyEclipse ---I'm using MyEclipse8.5, which itself comes with a plugin called maven4myeclipse, which only needs to be activated and configured.

Activation method: Window-->preference-->myeclipse-->maven4myeclipse, tick check box (Enable mave4myeclipse features).

Configuration method: Just under the node that the activation method opens, there is a MAVEN node, which expands the node, primarily configuring two nodes under it, as follows:

Installations: This node uses the built-in MAVEN by default, we need to use our installed Maven, point "add", add a maven that we externally install, note that after adding it, tick on.

User Settings: The default is the. m2/settings.xml file in the C-drive user directory, where you configure the externally installed MAVEN usage profile, as I am using the MAVEN installation directory under the conf/ Settings.xml file, select the "Update Settings" button below and don't forget to click on it.

3. Use MyEclipse to import a project created by Maven :

There are two ways to import a tutorial here:

1) use MyEclipse General engineering to import, the steps are as follows:

1> Open DOS First, run under the project Root (mywebapp): MVN eclipse: When eclipse---finishes running, you will find two more files in the project directory. Classpath and. Project, which is the project file for Eclipse, and of course MyEclipse also recognizes

2> Use the Import function in MyEclipse, select File-->import...-->existing Projects into workspace, select Project Catalog, import

3> associated maven, after the project is just a common Java project, and will not be associated with MAVEN plug-in, at this time in the project right click-->maven4myeclipse-->enable Dependency Management, so that the project is associated with the Maven plugin (the link will have an M ID on the upper left corner of the project root node).

2) Use the MAVEN project in MyEclipse to import the following steps:

1> Use the Import function in MyEclipse, choose File-->import...-->existing Maven Projects (here), select the project directory, import. ---here to import into, MyEclipse may update the index, very slow, we can cancel (in the Progress panel midpoint that big red box), then the project came in, but did not perform the operation, such as Maven Dependcy check, and so on, at this time 2nd step operation.

2> Update project configuration, right-click Project-->maven4myeclipse-->update Project Config

4. Complete the project's directory structure , the 1th step in the creation of the MAVEN project directory is not complete, such as our Java code, our test directory, etc., are manually created, and complete as follows:

C code
  1. MyWebApp
  2. +---Pom.xml
  3. +---SRC
  4. +---Main
  5. +---Resources
  6. +---java << add
  7. +---WebApp
  8. +---index.jsp
  9. +---Web-inf
  10. +---web. xml
  11. +---Test << add
  12. +---resources << add
  13. +---java << add
  14. +---target <<eclipse auto-add
  15. +---Classes <<eclipse auto-add
  16. +---test-classes <<eclipse auto-add


5. Add MyEclipse Web Project features

So far, we've just imported a maven webapp into the MyEclipse, but in MyEclipse it's just a Java generic Maven project, and we're going to add the MyEclipse Web Project feature to it.

Select Project-->myeclipse-->project capabilities-->add Web Project Capabilites, set the parameters in the pop-up window as follows, then select Yes in the next pop-up window. So our project is Web engineering (notice that the project icon is changed, and MyEclipse automatically relies on Jee's package).


6. Configure the project properties, open the Project Properties panel ---This step is very important, are some of the details of the configuration, indispensable ah

1) Java Build Path

1> Source

Add Src/main/java, Src/test/java, src/test/resources as the source folder, there is no need to detail it, click "Add Folder" on the line.

The "Default output folder" of the minimum face is modified to "mywebapp/src/main/webapp/web-inf/classes"---this is important.

Modify the output directory of these source folders, where Main/java and main/resources output to the default output folder, while Test/java and test/resources output to target/ Test-classes, (How to modify the---click on the output Folder under each node, then click on the right of the Edit button on the line) the final setting results are as follows:


2> Order and Export

In order to show good-looking, adjust the display order, not elaborate, very simple, look:


2) Java Compiler

Notice the above picture, my project shows JDK is 1.4, so to change to the version we want, here is not detailed, should be changed.

3) Myeclipse-->web This one is used to modify the Web features of the setup project, such as:

Well, the project for a MyEclipse Web project + Maven WebApp is built. The rest is to develop and debug the Web in MyEclipse and finally use MAVEN to package, of course, use Maven's dependency feature (add the jar package that you want to rely on directly in Pom.xml, and then refresh the project to automatically import). The attachment is a created SPRINGMVC HelloWorld that can be used as a template. -------OK-------turn from: http://b-l-east.iteye.com/blog/1246482

MyEclipse + maven Developing a detailed configuration process for Web engineering

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.