You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
servlet context parameters will be replaced by ServletWebServerFactoryCustomizer when providing a custom TomcatServletWebServerFactory
I used @Bean to customize TomcatServletWebServerFactory,and set the servlet context parameters, but the parameters replaced by ServletWebServerFactoryCustomizer get from org.springframework.boot.autoconfigure.web.ServerProperties, Is this a bug ?
Here is my @Bean code
@Bean
public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
TomcatServletWebServerFactory tomcatServletWebServerFactory =
new TomcatServletWebServerFactory();
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("param1", "value1");
hashMap.put("param2", "value2");
tomcatServletWebServerFactory.setInitParameters(hashMap);
return tomcatServletWebServerFactory;
}
But the following code will replace my parameter settings
The text was updated successfully, but these errors were encountered:
This is happening because the WebServerFactoryCustomizers are applied not just to the auto-configured TomcatServletWebServerFactory bean but also to a user-provided TomcatServletWebServerFactory bean. Ideally, we'd like the customizers to apply only to the auto-configured bean as that aligns with the other customizers. This would, however, be a breaking change and we've decided to hold off on this till 3.0.
@brucelwl For your case, you would need to configure a bean of type WebServerFactoryCustomizer which would be ordered so that it is applied after ServletWebServerFactoryCustomizer. You could either move all of your customization logic there instead of adding a bean for TomcatServletWebServerFactory, or just move the bits that overridden by ServletWebServerFactoryCustomizer.
mbhave
changed the title
servlet context parameters will be replaced by ServletWebServerFactoryCustomizer when providing a custom TomcatServletWebServerFactory
Customizers for WebServerFactory should only apply to auto-configured WebServerFactory bean
Dec 2, 2019
servlet context parameters will be replaced by
ServletWebServerFactoryCustomizer
when providing a customTomcatServletWebServerFactory
I used
@Bean
to customizeTomcatServletWebServerFactory
,and set theservlet context parameters
, but the parameters replaced byServletWebServerFactoryCustomizer
get fromorg.springframework.boot.autoconfigure.web.ServerProperties
, Is this a bug ?Here is my
@Bean
codeBut the following code will replace my parameter settings
The text was updated successfully, but these errors were encountered: