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:无法启动组件 [StandardEngine [Tomcat] .StandardHost [localhost] .TomcatEmbeddedContext [/ path]] 在java.util.concurrent.FutureTask.report(FutureTask.java:122)[na:1.8.0_144]