我有一个springboot应用程序,我试图在Openshift Tomcat 7(JBoss EWS 2.0)中部署。一旦我重新启动服务器,我就会收到控制台消息
public static void main(String[] args) throws Exception {
new Service().run(args);
}
@Override
public void run(ServiceConfig config, Environment environment) throws Exception {
Injector injector = Guice.createInjector(new ExtendingModule(config, environment));
.... // not altering metrics here
}
它表示部署成功但我在部署时并没有获得经典的弹簧徽标(如下所示),并且所有API都提供了404.
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
下面是我的servlet初始化程序
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.2.RELEASE) I am not getting this in console.
为什么会发生这种情况的原因?
答案 0 :(得分:1)
尝试在主Spring-Boot Application类中扩展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);
}
}