Convert the maven project created in eclipse to a dynamic web project

 

How to create Maven project in eclipse jee and convert it to Dynamic web project

Note: This document is only for the following eclipse versions, as shown in the figure

How to create Maven project in eclipse jee and convert it to Dynamic web project

For convenience, I put my local compressed package in the micro cloud network disk, you can download it directly, jee, subversion, m2eclipse are all integrated, download address

Link: http://pan.baidu.com/s/1i3pDNd7

1. Create a maven project

  1. Select File->New->Other->Maven->Maven Project in the menu bar of eclipse
  2. After the next step, select Create a simple project (skip archetype selection), as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  3. After the next step, enter Group Id, Archive Id, Packaging and click Finish, as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  4. After the successful creation of the file directory, as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

2. Dynamic Web Project converted to java

  1. Right-click on the Project name and select Properties
  2. Select Project Facets->Convert to Faceted from..., as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  3. Select Dynamic Web Module, Version is 2.5 (I haven't tested whether it is feasible for version 3.0), select Java, Version is 1.6, and click Further configuration available... as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  4. Modify the Content directory to /src/main/webapp/, click OK, as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  5. Finally, click OK of Properties for showcase to complete the conversion, and the final directory structure is as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

3. Modify the Java Build Path

  1. Right-click on the Project name and select Properties
  2. Select Java Build Path, remove JRE 1.5 version, and then click Add Library, as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  3. Select JRE System Library, click Next, as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  4. 选择你设置的jdk6版本,点击Finish,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  5. 最后点击OK,完成设置,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

四.修改Java Compile

  1. 右键点击Project的名称,选择Properties
  2. 选择Java Compiler,并选择Compiler compliance level为1.6,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

五.修改Deployment Assembly

  1. 右键点击Project的名称,选择Properties
  2. 选择Deployment Assembly,并点击Add,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  3. 选择Java Build Path Entries,点击Next,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  4. 选择Maven Dependencies,点击Finish,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  5. 最好点击OK,完成设置,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

六.设置Server Apache Tomcat

  1. 菜单栏选择Window->Show View->Servers
  2. 点击new server wizard,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  3. 选择Tomcat v6.0 Server,点击Next,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  4. 选择Browse,选择正确的Apache Tomcat的安装目录,然后点击Next,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  5. 选择要部署的项目如showcase,然后点击Add,点击Finish,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web projectxxx

    注意:

    在Add and Remove的时候提示这个:Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modulesHow to create Maven project in eclipse jee and convert it to Dynamic web project

    How to create Maven project in eclipse jee and convert it to Dynamic web project

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  6. 完成设置后的项目如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  7. 在Servers View上双击Tomat v6.0 Server at localhost[Stopped Republish],如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  8. 修改项目的部署目录为Tomcat installtion目录,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  9. 修改项目的访问路径,即去掉比如http://localhost/showcase/目录中的showcase,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  10. 关掉Auto reloading enabled,这样不用每次修改文件就自动部署,如图

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  11. Right-click Tocmat v6.0 Server at localhost[Stopped Republish], click Clean to complete the deployment of the web project, as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

  12. Finally, the deployment in the Tomcat directory was successful, as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

7. Run the project in Apache Tomcat

  1. Select Debug to debug the project, and select Run to run the project, as shown in the figure

    How to create Maven project in eclipse jee and convert it to Dynamic web project

Guess you like

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