MAVEN components to create a Web project, MAVEN benefits a lot of, but in the creation of the project, there are many problems, many bad, the internet to find a lot of information, seemingly did not solve the problem.
Environment: jdk1.7.0_80,eclipse4.4,maven3.2.1
Note: Test the jdk1.8.0_65, follow the same steps, seemingly can not solve the problem, if you have a solution, you can tell me, thank you.
Question 1, the superclass "Javax.servlet.http.HttpServlet" is not found on the Java Build Path
Workaround: This is because there is no Java EE jar package resulting in the Pom.xml file to add the following XML fragment to solve the problem
<!--importing Java EE jar packages -<Dependency> <groupId>Javax</groupId> <Artifactid>Javaee-api</Artifactid> <version>7.0</version></Dependency>
The WebApp project created by Maven is dependent on jdk1.5 by default and modifies the JDK version
Workaround: In the Mavne installation directory to find the Conf folder inside the Settings.xml file, the original file inside the <profiles></profiles> node inside the content has been commented out, Now add the following XML fragment below the node
< Profile> <ID>jdk-1.7</ID> <activation> <Activebydefault>True</Activebydefault> <JDK>1.7</JDK> </activation> <Properties> <Maven.compiler.source>1.7</Maven.compiler.source> <Maven.compiler.target>1.7</Maven.compiler.target> <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion> </Properties> </ Profile>
After saving, find the project file in Eclipse, right click Mavne-->update projects ... Can.
Question three, cannot change version of the project facet Dynamic Web Module to 3.0.
The default Dynamic Web module for MAVEN-created WebApp projects is version 2.3, because the JDK is 1.7, and I need to modify the Dynamic Web module version to 3.0 or more
Workaround: The project right-click Property pops up as follows form
A, this time to create a new normal Dynamic Web project (first built, the later will use the Web. XML content), and then find maven new WebApp project Webxml file, modified before and after the control
After modification
The specific XML fragment is:
<?XML version= "1.0" encoding= "UTF-8"?><Web-appXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns= "Http://java.sun.com/xml/ns/javaee"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"ID= "webapp_id"version= "3.0"> <Display-name>Archetype Created Web Application</Display-name></Web-app>
B, find the location of the project on the disk, and then into the. settings file, find org.eclipse.wst.common.project.facet.core.xml This XML file, the contents are as follows:
<?XML version= "1.0" encoding= "UTF-8"?><Faceted-project> <fixedfacet= "Wst.jsdt.web"/> <installedfacet= "Jst.web"version= "2.3"/> <installedfacet= "Wst.jsdt.web"version= "1.0"/> <installedfacet= "Java"version= "1.7"/> <installedfacet= "Jst.jaxrs"version= "2.0"/></Faceted-project>
Change the version number of <installed facet= "Jst.web" version= "2.3" to 3.0 and then right-click/> Maven-->update in Eclipse.
Now that the Web project doesn't have any errors with Maven Configration, let's summarize the steps:
First, in the eclipse4.4 configuration mavne3.2, in its installation directory found conf file inside the settings.xml, initialize the JDK and the dependent version of the JDK.
Ii. Modify the directory where the item is located. Settings-->org.eclipse.wst.common.project.facet.core.xml, modify the version number of the Jst.web.
Third, modify the project inside the Web. XML inside the Web-app version number.
Iv. in Eclipse, Project right-click Mavne-->update Projetcs
Maven3.2 issues and solutions during the creation of WEBAPP projects