BearerTokenAccessDeniedHandler 类定义 未找到
2022-09-04 07:10:14
我正在尝试使用spring boot 2.1.1和spring sec 5的演示项目,作为OAuth2资源服务器,但是当我尝试运行以下内容时
环境网络
- 弹簧靴 2.1.1 发布
弹簧安全核心 5.1.2
爪哇 8
法典
@RestController
@SpringBootApplication
// @EnableResourceServer
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@GetMapping("/hello")
public String sayHello() {
return "Hello World";
}
@Configuration
static class MyWebSecurityConfigurerAdapter extends
WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests().anyRequest().authenticated()
.and()
.oauth2ResourceServer().jwt(); // <--- throws error
}
}
}
这会引发错误
工厂方法'springSecurityFilTerChain'抛出异常;nested exception is java.lang.NoClassDefFoundError: org/springframework/security/oauth2/server/resource/web/access/BearerTokenAccessDeniedHandler
建
我的依赖项如下所示
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-security')
implementation(group: 'org.springframework.security.oauth.boot', name: 'spring-security-oauth2-autoconfigure', version: '2.1.1.RELEASE')
implementation(group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.3.4.RELEASE')
}