First, the environment
Os:win7
jdk:1.6
Maven:3
Eclipse:jee3.6+m2eclipse
Tomcat:6
Ii. creating a Web project built by Maven
1. Create Maven Project
MVN archetype:generate
In the list of archetype that appears, you can select an appropriate number, for example
197:remote-Struts2-archetype-blank (-)
Then there will be a MAVEN project in the work space
Execute MVN eclipse:eclipse
The project catalog adds some catalogs
2. Import Maven project in eclipse
If you build a Maven project with M2eclipse, you save two steps.
3. Make Maven project a dynamic Web PROJTCT modified by Eclipse. project Files or
4. Modify project fact in Eclipse to select Java and Dynamic Web project two items.
You should then be able to join the project to the Tomcat deployment, but will automatically join the Webconent directory in the project, and the default settings will publish the content under WebContent to/from
Need to be modified to Src/main/webapp directory, there are two ways.
One is to modify the org.eclipse.wst.common.component under the. setting in the Project catalog.
<wb-resource deploy-path= "/" source-path= "/src/main/webapp"/>, delete webconent directory
Here, Eclipse has taken over the management of Web Engineering from MAVEN.
Two deploying web apps to containers in eclipse
6. Add the Web project to the list of Tomcat publications.
If not, it may be that the version of the Sevlet container is too high. Modify:
If you start, you will find that the java.lang.ClassNotFoundException exception is reported. This is because Maven's dependency packages are not published together in Tomcat
Also to set up the deployment
Right-click Project in Eclipse, select maven-->enable Dependency Management
Locate the Deployment assembly configuration item in the project properties--"add-->referenced Projects classpath Entries-->next
In the window that appears, locate the project under which you want to configure a MAVEN dependencies item, tick
Mvn12.png
Mvn13.png
Even so, I also encountered strange things that jar packages could not be published to the Lib directory. Later the project was opened. Classespath found one of these.
In the Java build Paths configuration item of the project properties, order and export-> will mavent dependencies item
Mvn14.png
Need to be value= ". /"Set to"/web-inf/lib "I think this is a bug. That's OK.
Precautions:
Once the deployment environment of Eclipse is debugged, try not to use MVN eclipse:eclipse again. Otherwise the above work will be done again.
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.