-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
Summary
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your configuration.
Configuration
@Configuration
@EnableWebFluxSecurity
public class WebSecurityConfig {
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
...
}
...
}
@Configuration
public class WebSocketConfiguration {
@Bean
public HandlerMapping handlerMapping() {
Map<String, WebSocketHandler> map = new HashMap<>();
map.put("/websocket", new WebSocketMessageHandler());
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setUrlMap(map);
mapping.setOrder(-1); // before annotated controllers
return mapping;
}
@Bean
public WebSocketHandlerAdapter handlerAdapter() {
return new WebSocketHandlerAdapter();
}
}
Version
spring boot 2.0.5.RELEASE
io.spring.platform:platform-bom:Cairo-SR4
org.springframework.cloud:spring-cloud-dependencies:Finchley.SR1
dependencies
...
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-websocket")
...
Solution
I tried again and found that it works well while using dependency of 'org.springframework:spring-websocket' instead of 'org.springframework.boot:spring-boot-starter-websocket'. In deed, spring-boot-starter-websocket depends on 'org.springframework:spring-webmvc' to case this issue. We can exclude 'org.springframework:spring-webmvc' to avoid it.
I suggest that spring-boot-starter-websocket does not depends on 'org.springframework:spring-webmvc' or there is another spring-boot-starter-webflux-websocket which depends on 'org.springframework:spring-webflux' instead of 'org.springframework:spring-webmvc'.