您好,登錄后才能下訂單哦!
1、添加<.packaging>war</.packaging>,打包為war包
<packaging>war</packaging>
2、不使用SpringBoot內置的Tomcat,添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
server.servlet.context-path=/MyProject
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(FileuploadApplication.class);
}
修改后的啟動文件為:
package qiu.fileupload;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class FileuploadApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(FileuploadApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(FileuploadApplication.class);
}
}
mvn clean package
打包成功后,在項目的根目錄下面會多出一個target目錄,該目錄下面有一個war包,名為:fileupload-0.0.1-SNAPSHOT.war。
注:此時訪問的端口以tomcat的端口為準。
http://localhost:8080/MyProject/register.html
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。