Using Spring Boot Web Application with Pivotal TC Server

后端 未结 1 804
没有蜡笔的小新
没有蜡笔的小新 2021-01-07 13:20

I refactored my project as a Spring Boot application from inside Spring Tool Suite. All the documentation shows how to create a self contained application with an embedded T

1条回答
  •  礼貌的吻别
    2021-01-07 13:23

    You can deploy a Spring Boot application to tc Server in the same way that you'd deploy it to any other standalone servlet container. There are three changes that you need to make:

    1. Extend SpringBootServletInitializer so that the container will bootstrap your application correctly:

      @Configuration
      @EnableAutoConfiguration
      @ComponentScan
      public class Application extends SpringBootServletInitializer {
      
          @Override
          protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
              return application.sources(Application.class);
          }
      }
      
    2. Convert the project to use war packaging. Maven example:

      
      
          
          war
          
      
      
    3. Mark your spring-boot-starter-tomcat dependency as provided so that embedded Tomcat doesn't conflict with the classes in tc Server. Maven example:

      
          org.springframework.boot
          spring-boot-starter-tomcat
          provided
      
      

    I'm not aware of any differences between the class-reloading capabilities of Tomcat and tc Server. Perhaps you have Spring Loaded configured in your tc Server instance? If so, you can use it with Spring Boot too.

    0 讨论(0)
提交回复
热议问题