Suggest setting spring.main.web-application-type=reactive if mvc on classpath.
See gh-2176K
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.cloud.gateway.support.MvcFoundOnClasspathException;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -38,6 +39,7 @@ public class GatewayClassPathWarningAutoConfiguration {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(name = "org.springframework.web.servlet.DispatcherServlet")
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
protected static class SpringMvcFoundOnClasspathConfiguration {
|
||||
|
||||
public SpringMvcFoundOnClasspathConfiguration() {
|
||||
|
||||
@@ -22,12 +22,20 @@ import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||
public class MvcFoundOnClasspathFailureAnalyzer
|
||||
extends AbstractFailureAnalyzer<MvcFoundOnClasspathException> {
|
||||
|
||||
/**
|
||||
* Message for MvcFoundOnClasspathException.
|
||||
*/
|
||||
public static final String MESSAGE = "Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.";
|
||||
|
||||
/**
|
||||
* Action for MvcFoundOnClasspathException.
|
||||
*/
|
||||
public static final String ACTION = "Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.";
|
||||
|
||||
@Override
|
||||
protected FailureAnalysis analyze(Throwable rootFailure,
|
||||
MvcFoundOnClasspathException cause) {
|
||||
String message = "Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.";
|
||||
String action = "Please remove spring-boot-starter-web dependency.";
|
||||
return new FailureAnalysis(message, action, cause);
|
||||
return new FailureAnalysis(MESSAGE, ACTION, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user