Deploy maven project on Eclipse

 

 

 

To create a maven project on Eclipse, it is recommended to use the latest version of Eclipse or above 4.5, why? Because you do not need to manually install the m2eclipse plugin to manage Maven projects

Therefore, it is recommended that you use the latest version of the eclipse mars2 4.5.2 development tool. Download address: http://www.eclipse.org/downloads/

Not much to say about the environment, it will.

1. Integrate eclipse, maven:

Start the eclipse development tool, click: Window--preferences--Maven--Installations

Then continue to select Maven--User Settings on the left, and set both configuration file directories to Maven directory\conf\settings.xml

Then click Update Settings to update the configuration. After clicking OK, the integration of Maven and Eclipse is completed.

 

 2. Resume maven project

1> Click the File-New-Other option to pop up a dialog box. Enter "maven" in the dialog box, select the "Maven Project" option,

Click the "next" button, as shown in the figure:

2>

 

3> Look clearly, don't choose the wrong one

4>Enter Group Id and Artifact Id fields, Artifact Id is the project name. Click the "Finish" button

 

 5> After the skeleton is built, you will find an error, it doesn't matter, ignore it first, and solve it later:

6> Next, you need to configure the related maven: you need to add the following Source Folder,

They are: src/main/resources, src/main/java, src/test/resources, src/test/java. But this step will go wrong:

1) Right-click on the project -->new-->Source Folder

2) Obviously it already exists, so you need to delete the original project --> right click on the project and select "Build Path" --> "Configuration Build Path..."

 

 3) Just face the "1)" step before proceeding. As shown in the figure: After repeating the construction of src/main/java, src/test/resources, and src/test/java, it is ok

4) Build it like this:

7>Configure Build Path: Right-click on the project and select "Build Path"-->Configuration Build Path.

 

 

 

 

 7> Convert the project to Dynamic Web Project

  (Maven is still the most commonly used project management tool today. To use Maven to manage Java Web projects, you first need to create a new Maven project and then convert it into a web project.

Right-click on the project and select properties, then click Project Facets on the left, check Dynamic Web Module, and click Apply-->OK. Ideally it should be possible to appear under the project

WebContent directory. If not, first go back to the Project Facets interface, uncheck Dynamic Web Module, and click Apply. Then re-tick, the following will appear

Now the link of "further configuration available", click to enter, and check to generate the web.xml file.

  After the WebContent is generated, cut the next two folders to src/main/webapp and delete the WebContent.

Right-click the project, select properties, select Deployment Assembly. Select WebContent and remove it. Then re-specify a web path, click Add, select Folder,

Click Next. Find the webapp directory under src/main and click Finish. Continue to click Add and select Java Build Path Entries. Point the current build path to Maven Dependency. Click Apply and OK. )

 1. Right-click the project-properties-select project facets, change java to 1.7, and select dynamic web module to 2.5 (cannot be modified directly, first uncheck dynamic web module,

Then apply. At this time, select 2.5 again, then check it again, and then click further configuration available as shown in the figure to change the content directory to src/main/webapp to confirm.

 

After completion, the directory looks like this

8> Deploy Tomcat

window-->preference

 

 

 Then it's ok

Right-click on the project -->properties-->Maven

 

 

The red cross is gone! You still need to modify pom.xml at this point

Right click on the project -->run as -->run configurations

This is the end of it, and by the way, there are many ways to deploy maven projects to tomcat, you can see what guodefu909 wrote:

http://www.cnblogs.com/guodefu909/p/4874549.html

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325854761&siteId=291194637