Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The mssing package org.springframework.web

Tags:

spring

maven

I continue learning maven and try to understand why I get this error package "org.springframework.web.servlet does not exist" when org.springframework.web dependecy already have defined in pom.

 <groupId>com.home.springtraining</groupId
<artifactId>SpringTrainingTemplate</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>SpringTrainingTemplate</name>
  <url>http://maven.apache.org</url>
  <properties>
<spring.version>3.1.1.RELEASE</spring.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
<dependency>
<groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${spring.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>${spring.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${spring.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>${spring.version}</version>
</dependency>
<dependency>    
    <groupId>commons-logging</groupId>  
    <artifactId>commons-logging</artifactId>  
    <version>1.1.1</version>  
</dependency>
<dependency>    
    <groupId>commons-io</groupId>  
    <artifactId>commons-io</artifactId>  
    <version>2.3</version>  
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.4</version>
</dependency>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>

Could you tell me why this error occurs?

like image 411
Winte Winte Avatar asked Sep 26 '12 14:09

Winte Winte


2 Answers

org.springframework.web.servlet is a part of Spring MVC, it's located in org.springframework:spring-webmvc artifact:

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-webmvc</artifactId> 
    <version>${spring.version}</version> 
</dependency> 

org.springframework:spring-web contains common functionality for using Spring in web applications, it's not tied to Spring MVC.

like image 143
axtavt Avatar answered Oct 22 '22 05:10

axtavt


add this dependency to your pom.xml

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
like image 2
Satya Avatar answered Oct 22 '22 05:10

Satya