ResourceServerConfig和 ModuleConfigImpl已配置,代码如下:
ResourceServerConfig:
@Configuration
@AllArgsConstructor
@EnableResourceServer
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
private TokenStore tokenStore;
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
resources.tokenStore(tokenStore);
//token不存在或错误时,异常处理
resources.authenticationEntryPoint(new SecurityAuthenticationEntryPoint());
}
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/**").permitAll()
.anyRequest().authenticated()
;
}
}
ModuleConfigImpl:
@Service
public class ModuleConfigImpl implements ModuleConfig {
@Override
public String getName() {
return "evaluation";
}
}
报错信息:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-01-28 10:43:08.181 ERROR 19577 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.ryxy.evaluation.config.ResourceServerConfig required a bean of type 'org.springframework.security.oauth2.provider.token.TokenStore' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.security.oauth2.provider.token.TokenStore' in your configuration.