gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 04:46:17 24 4
gpt4 key购买 nike

我在下面添加到我的 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 版本后的 spring-web 中可用 [ 1 ].

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

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

关于java - 添加 "spring-security-web"后导入 org.springframework.web.bind.annotation.RestController 无法解决错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36985748/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com