创建的Maven 工程,超类以上找不到"javax.servlet.http.HttpServlet" Java Build Path
在pom.xml 中添加
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
或者
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.4_spec</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
建立web项目还常需要的jar包
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<type>jar</type>
</dependency>
具体版本可以去提供Maven 库里查询一下 如:http://mvnrepository.com
也可以在maven 项目中设定仓库,如下:
<!-- 设定主仓库,按设定顺序进行查找。 -->
<repositories>
<!-- 如有Nexus私服, 取消注释并指向正确的服务器地址.
<repository>
<id>nexus-repos</id>
<name>Team Nexus Repository</name>
<url>http://192.168.11.36:8888/nexus/content/groups/public</url>
</repository> -->
<repository>
<id>oschina-repos</id>
<name>Oschina Releases</name>
<url>http://maven.oschina.net/content/groups/public</url>
</repository>
<repository>
<id>java-repos</id>
<name>Java Repository</name>
<url>http://download.java.net/maven/2/</url>
</repository>
<repository>
<id>springsource-repos</id>
<name>SpringSource Repository</name>
<url>http://repo.spring.io/release/</url>
</repository>
<repository>
<id>central-repos</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>central-repos2</id>
<name>Central Repository 2</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>activiti-repos</id>
<name>Activiti Repository</name>
<url>https://maven.alfresco.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>activiti-repos2</id>
<name>Activiti Repository 2</name>
<url>https://app.camunda.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>thinkgem-repos</id>
<name>ThinkGem Repository</name>
<url>http://git.oschina.net/thinkgem/repos/raw/master</url>
</repository>
<repository>
<id>thinkgem-repos2</id>
<name>ThinkGem Repository 2</name>
<url>https://raw.github.com/thinkgem/repository/master</url>
</repository>
</repositories>
<!-- 设定插件仓库 -->
<pluginRepositories>
<!-- 如有Nexus私服, 取消注释并指向正确的服务器地址.
<pluginRepository>
<id>nexus-repos</id>
<name>Team Nexus Repository</name>
<url>http://192.168.11.36:8888/nexus/content/groups/public</url>
</pluginRepository> -->
<pluginRepository>
<id>oschina-repos</id>
<name>Oschina Releases</name>
<url>http://maven.oschina.net/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
该贴被panpan.nie编辑于2015-12-25 14:20:26