OpenLiberty 18.0.0.3 支持自动禁用嵌入式 Tomcat 容器。但是,当 SpringBoot 应用程序在 SpringBoot 应用程序类中包含 EmbeddedServletContainerFactory @Bean 时,这似乎不起作用。
如何使用外部配置/xml 文件或其他禁用此 EmbeddedServletContainerFactory @Bean,以便 Liberty 可以覆盖嵌入式容器?
package com.mw.springboot.jaxws;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class SpringCxfApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCxfApplication.class, args);
}
// Register Servlet
@Bean
public ServletRegistrationBean servletRegistrationBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new MyServlet(), "/myServlet");
return bean;
}
// how can this be disabled through external configuration?
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory =
new TomcatEmbeddedServletContainerFactory();
return factory;
}
}
报告以下错误:
88856 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase
:子容器在启动过程中失败java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: 无法在 java.util.concurrent.FutureTask.report(FutureTask. java:122) [na:1.8.0_144]