今天我重建我的项目,并收到以下错误消息:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'SecurityConfig' may not be final. Remove the final modifier to continue.
Offending resource: class path resource [com/easythings/booky/config/SecurityConfig.class]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:72) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
如果我将班级更改为“开放”,则会遇到有关该班级字段的下一个错误。
班级:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true, jsr250Enabled = true, prePostEnabled = true)
class SecurityConfig : WebSecurityConfigurerAdapter() {
@Autowired
internal var customUserDetailsService: CustomUserDetailsService? = null
@Autowired
private val unauthorizedHandler: JwtAuthenticationEntryPoint? = null
@Bean
fun jwtAuthenticationFilter(): JwtAuthenticationFilter {
return JwtAuthenticationFilter()
}
@Throws(Exception::class)
public override fun configure(authenticationManagerBuilder: AuthenticationManagerBuilder?) {
authenticationManagerBuilder!!
.userDetailsService<UserDetailsService>(customUserDetailsService)
.passwordEncoder(passwordEncoder())
}
@Bean(BeanIds.AUTHENTICATION_MANAGER)
@Throws(Exception::class)
override fun authenticationManagerBean(): AuthenticationManager {
return super.authenticationManagerBean()
}
@Bean
fun passwordEncoder(): PasswordEncoder {
return BCryptPasswordEncoder()
}
@Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http
.cors()
.and()
.csrf()
.disable()
.exceptionHandling()
.authenticationEntryPoint(unauthorizedHandler)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/",
"/favicon.ico",
"/**/*.png",
"/**/*.gif",
"/**/*.svg",
"/**/*.jpg",
"/**/*.html",
"/**/*.css",
"/**/*.js")
.permitAll()
.antMatchers("/api/auth/**")
.permitAll()
.antMatchers("/api/user/checkUsernameAvailability", "/api/user/checkEmailAvailability")
.permitAll()
.antMatchers(HttpMethod.GET, "/api/users/**")
.permitAll()
.anyRequest()
.authenticated()
http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter::class.java)
}
}
昨天有效,我没有更改代码中的任何内容。我只需要做的一项更改就是在配置中再次设置JVM版本。
如何解决?