1. 程式人生 > >Springboot專案部署到外部Tomcat

Springboot專案部署到外部Tomcat

這裡提供maven專案的解決方法:

1.將專案的啟動類Application.java繼承SpringBootServletInitializer並重寫configure方法

package com;

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 Application extends SpringBootServletInitializer {

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

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}

2.在pom.xml檔案中,project下面將package標籤修改為war,沒有則增加war的package標籤