【问题标题】:Spring boot 1.5.2 not deploying in Openshift Tomcat 7(JBoss EWS 2.0)Spring boot 1.5.2 未部署在 Openshift Tomcat 7(JBoss EWS 2.0)中
【发布时间】:2017-06-13 05:09:14
【问题描述】:

我有一个 springboot 应用程序,我正尝试在 Openshift Tomcat 7(JBoss EWS 2.0)中部署它。重新启动服务器后,我会收到以下控制台消息

INFO: Deploying web application archive /var/lib/openshift/-----xxxx-----/app-root/runtime/dependencies/jbossews/webapps/api.war
Jun 13, 2017 12:54:41 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/-----xxxx-----/app-root/runtime/dependencies/jbossews/webapps/api.war has finished in 67,610 ms

它说部署成功,但在部署时我没有得到经典的 spring 徽标(如下所示),并且所有 API 都给出 404。

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.2.RELEASE) I am not getting this in console.

下面是我的 servlet 初始化器

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(ApicApiNewApplication.class);
    }

}

为什么会发生这种情况?

【问题讨论】:

    标签: java spring tomcat spring-boot openshift


    【解决方案1】:

    尝试在您的主 Spring-Boot 应用程序类中扩展 SpringBootServletInitializer,如下所示,

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.web.support.SpringBootServletInitializer;
    
    @SpringBootApplication
    public class DemoApplication extends SpringBootServletInitializer {
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(DemoApplication.class);
        }
    
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    }
    
    猜你喜欢
    • 2014-06-11
    • 1970-01-01
    • 1970-01-01
    • 2016-08-26
    • 1970-01-01
    • 1970-01-01
    • 2016-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多