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

Source: Internet
Author: User

There are two solutions in this essay, and the other is a third one in the passage, please click here

1. Error

This is an error message: Thesuperclass "Javax.servlet.http.HttpServlet" is not found on the Java Build Path

2. Error Analysis:

I was thinking about the lack of a web container, the servlet container.

So I added the Tomcat plugin to the Pom.xml file:

1 <Plugins>2     <plugin>                        3         <groupId>Org.apache.tomcat.maven</groupId>4         <Artifactid>Tomcat7-maven-plugin</Artifactid>5         <version>2.2</version>6         <Configuration>7         <Port>8050</Port>8         <Path>/</Path>9         </Configuration>Ten     </plugin> One </Plugins>

But the problem is not solved, or reported the same mistake.

3.1 Solutions

Then try adding the following in the Pom.xml file:

1 <Dependency>2     <groupId>Javax.servlet</groupId>3     <Artifactid>Servlet-api</Artifactid>4     <version>2.5</version>5     <Scope>Provided</Scope>6 </Dependency>7 <Dependency>8     <groupId>Javax.servlet</groupId>9     <Artifactid>Jsp-api</Artifactid>Ten     <version>2.0</version> One     <Scope>Provided</Scope> A </Dependency>    

The error is resolved.

3.2 Then tried to delete the Tomcat plugin from the Pom.xml file, and the project still had no problem.

Then he tried to delete the Servlet.api and Jsp-api in the Pom.xml file.

Then right-click on the project-->build path-->add libraries-->server Runtime ...

can also solve the problem, the project does not error.

4. Analyze 3.1, 3.2 two solutions:

Adding the Tomcat plugin to the Pom.xml file does not rely on the SERVLET-API and Jsp-api, so you also need to manually rely on the two jar packages.

But by right-clicking on the project-->build path-->add libraries-->server Runtime ... The way to add Tomcat will also depend on the Servlet API and the Jap API.

5. There is also a third solution

Please click here to view my other essay.

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

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.