springBoot内置如何修改内嵌tomcat中server.xml中的配置信息?

springBoot内置如何修改内嵌tomcat中server.xml中的配置信息?
修改配置文件$tomcat/conf/server.xml如下:
autoDeploy="false" //自动部署
deployOnStartup="false" //在启动时自动部署

赐你一段机缘
@Configuration
public class zhtbsConfig {
@Bean
public TomcatServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcatfac = new TomcatServletWebServerFactory();
WebServer webServer= tomcatfac.getWebServer();
Tomcat tomcat = ((TomcatWebServer) webServer).getTomcat();
tomcat.getHost().setAutoDeploy(true);
tomcat.getHost().setDeployOnStartup(true);
return tomcatfac;
}
}

以SpringBoot版本2.7.1为例:


public class CustomApplicationContextFactory implements ApplicationContextFactory {

    @Override
    public ConfigurableApplicationContext create(WebApplicationType webApplicationType) {
        return (webApplicationType != WebApplicationType.SERVLET) ? null : new AnnotationConfigServletWebServerApplicationContext(){
            @Override
            protected void onRefresh() {
                super.onRefresh();
                Host host = ((TomcatWebServer) getWebServer()).getTomcat().getHost();
                host.setAutoDeploy(false);
                host.setDeployOnStartup(false);
            }
        };
    }

}

再在META-INF/spring.factories中添加以下配置:
org.springframework.boot.ApplicationContextFactory=your.package.CustomApplicationContextFactory