2011-12-07 134 views
10

我缺少什么依赖性?我目前正在使用:org.springframework.web.bind.annotation.RequestMapping缺少什么依赖关系?

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-web</artifactId> 
    <version>3.0.5.RELEASE</version> 
</dependency> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-webmvc</artifactId> 
    <version>3.0.5.RELEASE</version> 
</dependency> 

错误即时得到的是: 进口org.springframework.web.bind不能得到解决

回答

13

我有同样的问题。花费数小时后,我遇到了解决方案,我已经添加了对“spring-webmvc”的依赖关系,但错过了“spring-web”。所以只需添加下面的依赖关系来解决这个问题。如果你已经有了,只需更新到最新版本。它肯定会起作用。

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-web</artifactId> 
    <version>4.1.6.RELEASE</version> 
</dependency> 
+0

感谢队友,也为我工作。你有没有任何想法,如果我们没有指定哪一个版本做春季下载?不是默认下载最新版本! – varunkr

+1

当我们没有指定“”标签时,它会抛出错误/异常。因此标签“”是强制性的。其次,如果您没有在此标记中指定版本,则需要指定版本标记“LATEST”/“RELEASE”(仅当您使用Maven 2.x时)。对于Maven 3.x,meta版本标记不再受支持。始终指向最新版本的依赖关系可能会在构建应用程序时产生问题。因此强烈建议使用版本的具体值。 – MAC

+1

欲了解更多详细信息,请查看[Stackoverflow](https://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency)和[Apache Maven](https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-PluginMetaversionResolution) – MAC

5

我不认为这个问题是依赖关系。我猜你在IDE上遇到了这个错误。然后只需刷新它。如果是月蚀,请尝试运行Maven->更新依赖项

0

我有同样的问题,但我用其他方式解决(因为在右键单击项目文件夹没有Maven选项卡apears只有当我在pom.xml上执行该操作时才能看到一个Maven选项卡):

所以我叮叮当然得到了那个错误,因为IDE(Eclipse)没有从Maven导入依赖关系。由于您使用的是Spring框架,并且您可能已经安装了STS,请右键单击项目文件夹Spring Tools - > Update Maven Dependecies。

我真的使用 Eclipse的JUNO m2eclipse的1.3.0 春IDEE 3.1

3

要解决,更新弹性框架工作到3.2.0或以上!

2

我想你正在使用Spring 3.0.5,你需要使用Spring 4.0。*这将解决你的问题。 。 org.springframework.web.bind.annotation.RequestMapping无法使用Spring的网络更早那么Spring的web 4.0 *

19

此解决方案有效,我有同样的问题和小时后,我想出了这个:

(1)打开你的pom.xml

(2)添加此相关性:

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>4.1.6.RELEASE</version> 
    </dependency> 


(3)运行项目

+0

谢谢,我只是更新的版本,因为spring-webmvc已经在我的pom – eeadev

1

有时在本地Maven回购中存在一些错误。因此,请关闭您的eclipse并从您的本地.m2中删除jar spring-webmvc,然后打开Eclipse并在项目上按 更新Maven Dependencies。

然后Eclipse会再次为您下载依赖关系。 那我如何解决同样的问题。

0

转到pom.xml的

添加此相关性:

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>4.1.6.RELEASE</version> 
    </dependency> 

使用命令提示符下,找到你的文件夹: - MVN清洁

1

我用弹簧web版4.3.7

它更改为工作4.1.7立即解决它。

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>4.1.7.RELEASE</version> 
    </dependency>