开发环境使用jdk1.8.0_60,把springboot 项目打成war包后,
部署到apache-tomcat-7.0.68时报错如下,换成apache-tomcat-8.0.9解决
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/my-springboot-web-0.0.1]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String; at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:149) at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131) at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5573) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) ... 10 more六月 22, 2017 12:19:15 上午 org.apache.catalina.startup.HostConfig deployWAR严重: Error deploying web application archive E:/Data/apache-tomcat-7.0.68/webapps/my-springboot-web-0.0.1.warjava.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/my-springboot-web-0.0.1]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:903) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
另外springboot项目打成war包部署到tomcat时需要改变启动方式,否则运行tomcat时war包只会解压,但是加载不了
import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.builder.SpringApplicationBuilder;import org.springframework.boot.context.web.SpringBootServletInitializer;@SpringBootApplication //- springboot项目,并配置扫描路径@EnableAutoConfiguration //- springboot自动配置,这个注解可以根据你依赖的包自动生成相关配置public class StartApp extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(StartApp.class, args); } /** * 需要把web项目打成war包部署到外部tomcat运行时需要改变启动方式 */ @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(StartApp.class); }
新闻热点
疑难解答