How to convert maven project to web application project?

馋奶兔 提交于 2019-12-10 10:08:28

问题


I want to convert a maven project to a web application project, which should contain web.xml. I am using eclipse juno 4.2 with m2e (maven integration for eclipse) plugin software.

Any reply would be appreciated.


回答1:


  • Install m2e-wtp
  • In your pom.xml, change or add the war packaging
  • right-click on project > Maven > Update project
  • m2e-wtp will create the src/main/webapp folder and add the Dynamic Web project Facet¤
  • manually add a WEB-INF folder under src/main/webapp
  • right-click on project > Java EE Tools > Generate Deployment Descriptor stub It will create a web.xml under src/main/webapp/WEB-INF/

¤ By default, the web facet is set to 2.5. You should update it, if needed, under project properties > Project Facets BEFORE generating the web.xml




回答2:


I assume your current project is a maven project which produces jar. Please confirm.

I have not come across any utility which can convert a jar project to a war project.

You have following two options -

  1. Simple open the pom.xml and change jar to war. Create folder webapp under src/main and create a web.xml
  2. Create a new web app project via maven command line choosing webapp archetype or via eclipse choosing maven webapp achetype. Define dependency to your jar project.

If you can provide more information based on my suggestion then probably I can help.



来源:https://stackoverflow.com/questions/16101839/how-to-convert-maven-project-to-web-application-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!