Eclipe New MAVEN Web project

Source: Internet
Author: User

Eclipse new MAVEN Web project:

1. Create a Web project
Blank---Right-click--->new---->other--->mavenproject--->filter webapp--->maven-archetype-webapp

Question 1:
The superclass "Javax.servlet.http.HttpServlet" is not found on the Java Build Path

Solution:
Dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<!--Tomcat Container has API to prevent runtime conflicts provided: compile, test classpath effective run invalid--
<scope>provided</scope>
</dependency>
Question 2:
did not appear Src/main/java
Src/test/java?
Solution:
1.JRE modified to locally installed JDK
In Selected items
JRE System libary Right-click---->build Path--->config Build path--->edit replaced with a locally installed JDK environment
Question 3:
An error xxxx?
Select items----Right-click--->maven--->update project

2.maven Project converted to Web project:

Select item----Right-click--->properties--->project Facets---> Tick Dynamic Web module and specify the corresponding JDK version
3. Check that the directory is in effect:
Src-->main-->webapp-->web-inf

Configuration of the 4.web project deployment:
Select item----Right-click--->properties--->depolyment Assembly--->remove Test folder
Note:
If the MAVEN project does not work correctly, check if Maven Dependencies this directory

5. Check the output directory of the file's classes file:
Select items----Right-click--->properties--->build path--->source---> Check src/main/java, Src/test/java, src/main/ Resources are configured correctly
6. Run the Web project
Web project Run server above:
Jetty
A lightweight Web server
1. Jetty:run
<build>
<finalName>maven-web</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.6.v20151106</version>
</plugin>
</plugins>
</build>

2.package:

<build>
<finalName>maven-web</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.6.v20151106</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Tomcat:

Package
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>


Summary of Problem Solving:
First step through problems view to determine where is the problem?

1. First check whether the specified local installation JDK is

2. Specific error specific treatment

3. MVN clean (excludes errors that you do not want to close)

4. Select the project---->maven--->update project

Eclipe New MAVEN Web project

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.