Spring Boot:不推荐使用SpringBootServletInitializer

时间:2016-08-09 05:52:25

标签: java spring-boot

我正在尝试按照this将Spring Boot应用程序部署到JBoss。它运行良好,但在1.4.0.RELEASE中不推荐使用 SpringBootServletInitializer 。我应该使用哪一个?

Maven依赖

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.RELEASE</version>
</parent>

Java代码

 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.web.SpringBootServletInitializer;

    @SpringBootApplication
    public class DemoApplication  extends SpringBootServletInitializer {
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    }

2 个答案:

答案 0 :(得分:147)

您正在使用org.springframework.boot.context.web.SpringBootServletInitializer这已被弃用。代替:

使用

org.springframework.boot.web.support.SpringBootServletInitializer

对于SpringBoot 2.0

org.springframework.boot.web.servlet.support.SpringBootServletInitializer

答案 1 :(得分:0)

您可以尝试-为我工作

import org.springframework.boot.web.servlet.ServletContextInitializer;