我创建了一个 Spring Boot 应用程序,然后创建了一个 war。
在我的本地服务器上,应用程序可以正常运行。
我将此应用程序重命名为 ROOT.war,使用 git 将其放入 webapps 目录并重新启动服务器,从而将此应用程序添加到 JBOSSEWS 盒中。
但是我总是找不到404。
tomcat 日志是:
new-host-3:jbossews JARVIS$ rhc tail jbossews
Aug 30, 2014 3:27:25 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Aug 30, 2014 3:27:25 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/openshift/540178a84382ec94b8000b75/app- root/runtime/dependencies/jbossews/webapps/ROOT.war
Aug 30, 2014 3:27:37 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/540178a84382ec94b8000b75/app-root/runtime/dependencies/jbossews/webapps/ROOT.war has finished in 11,864 ms
Aug 30, 2014 3:27:37 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.10.90.1-8080"]
Aug 30, 2014 3:27:37 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 12059 ms
最佳答案
确保您的主类 Application 扩展了 SpringBootServletInitializer
Initialize the servlet
By converting this into a WAR file with no XML files, you need a different signal to the servlet container on how to launch the application.
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class HelloWebXml extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
HelloWebXml
is a pure Java class that provides an alternative to creating aweb.xml
. It extends theSpringServletInitializer
class. This extension offers many configurable options by overriding methods.
关于spring - 包含在 openshift tomcat 上手动部署的 spring boot 应用程序的 WAR 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25580218/