Spring Boot:不推荐使用SpringBootServletInitializer

Aun*_*ein 61 java spring-boot

我想通过以下部署春季启动应用到JBoss .它运行良好但SpringBootServletInitializer在1.4.0.RELEASE中已弃用.我应该使用哪一个?

Maven依赖

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

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);
        }
    }
Run Code Online (Sandbox Code Playgroud)

Ama*_*har 157

您正在使用org.springframework.boot.context.web.SpringBootServletInitializer此功能已弃用.代替:

使用

org.springframework.boot.web.support.SpringBootServletInitializer

对于SpringBoot 2.0

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

  • 对于spring boot 2.0.0,你需要使用"org.springframework.boot.web.servlet.support.SpringBootServletInitializer" (5认同)
  • 为什么它现在在支持包中?在新版本中是否有另一种创建servlet的方法? (2认同)