Most of the apes that use Java are probably Web projects, right? In the process of learning maven, of course, the first is to create a WebApp project.
Oneself in the process of trying, encountered a lot of problems. I have documented the detailed procedures for future reference.
steps:If you do not have a MAVEN development environment in place, please refer to the previous article:maven Learning notes-Environment building Open Eclipse, menu bar Choose File, New, and other, and find Maven project in the popup dialog box. In the popup dialog box for the new MAVEN project,Don'tTick the first item "Create A simple Project", as shown in, click Next. Locate and select "Maven-archetype-webapp" in the list and click Next. As shown in:
Fill in the relevant information of the project, Finish.
Construction of the project structure such as:
After the project is generated, the JRE version defaults to 1.5 and we need to modify it to a later version: In the project's Pom.xml file, add the following configuration:
<Build> <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-compiler-plugin</Artifactid> <version>2.1</version> <Configuration> <Source>1.7</Source> <Target>1.7</Target> </Configuration> </plugin> </Plugins> </Build>
(You can also modify the Settings.xml global configuration to have Maven set a specific version of the JRE by default, which is not written here first)
When you're finished, select Maven->update project by selecting the item right-click and the pop-up menu.
Enter the Java Build Path configuration page for the project:
The discovery item also exists as shown in the error:
Just set the JRE System library in the library tag to native default (you don't know why)
Double-click the JRE System Library item to eject the JRE Settings screen:
Directly select workspace Default JRE. After completion, the Discovery project also has three error, as shown in. Don't worry, we'll fix it one at a.
Project, index.jsp displays an error with the error message: The superclass "Javax.servlet.http.HttpServlet" is not found on the Java Build Path at this time because of the lack of serv Let-api, Jsp-api, Jstl and other packages. We don't need one to bring in the package because the servlet containers such as Tomcat provide this package. Set up a running environment in eclipse for your project:
If there is no server configuration, please configure a server such as Tomcat beforehand. Select Tomcat and click Finish to see that the project no longer has the two servlet error. There is one error left: Java compiler level does not match the version of the installed Java project facet.
Open the project facet settings item for the item, for example, set the version of Java to 1.7, OK.
It should be no longer an error. But we also need to set a higher version of the Dynamic Web module in the project facet. As shown, I set it to version 3.0.
The following error may be reported: Cannot change version of the project facet Dynamic Web Module to 3.0 I find a lot of information on the Internet and find that all the solutions are completely ineffective. But by chance, I found a simple way to solve the problem (I don't know if it's generic or special in my own environment). Here's how to do this: uncheck the dynamic WEB module before clicking Apply. And then put the hook on the hook, found that no error has been made. Set it up, run it and try it:
Open link after run: http://localhost:8080/hello-maven-web/index.jsp found browser reported 404 error. To check the deployment configuration of the project:
WebApp This directory deployment path was found to be less. Click "Add", select "folder" in the Pop-up dialog box, select the WebApp folders:
Click Finish on the line. Run again and finally see Hello world!
MAVEN Learning notes-Creating a Java WebApp project using the Eclipse plugin