导入 org.springframework.web.bind.annotation.RestController 无法解决错误后添加"spring-security-web"



我在下面添加到我的pom.xml 中

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

解决我的servlet-config.xml 中的错误

 <http pattern="/api/login" security="none" /> // error line
 // error : The classes from the spring-security-web jar (or one of its dependencies) are not available. You need these to use <http>: 
 org.springframework.security.web.FilterChainProxy

但当我用上面的条目修改pom时,我的@RestController出现了一个错误。

在线

import org.springframework.web.bind.annotation.RestController;

它说"导入org.springframework.web.bind.annotation.RestController无法解析"

切换到最新版本(当前为4.3.3.RELEASE)。Spring@RestController注释自4.0.1[1]版本以来仅在Spring-web中可用。

在Maven中,这意味着在pom.xml文件中包含/替换依赖项:

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

最新更新