修改pom.xml文件
<packaging>jar</packaging>
修改为
<packaging>war</packaging>
添加Tomcat部署依赖包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
增加ServletInitializer初始化类
package com.moxi;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(MoxiApplication.class);
}
}
上面的MoxiApplication.class是项目自动生成的main启动类:
package com.moxi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MoxiApplication {
public static void main(String[] args) {
SpringApplication.run(MoxiApplication.class, args);
}
}
打包
到项目目录下执行:
mvn package
执行如下:
mvn package
target目录下已经生成了war包了:
生成war包
部署
最简单的办法,直接复制war包到Tomcat的webapp目录下,启动tomcat。
浏览器加上项目路径访问:http://localhost:8080/moxi-0.0.1-SNAPSHOT/admin/login
Spring Boot(1)工具安装:
http://www.jianshu.com/p/fb6ed37c90eb
Spring Boot(2)新建Spring Boot工程
http://www.jianshu.com/p/00fd73f515f6
Spring Boot(3)整合Mybatis
http://www.jianshu.com/p/8401e9304fa0
Spring Boot(4)整合thymeleaf
http://www.jianshu.com/p/8d2cc7207fb2
Spring Boot(5)一个极简且完整的后台框架
http://www.jianshu.com/p/923d26d705ed
Spring Boot(6)jar方式打包发布
http://www.jianshu.com/p/9cf6faa8595e
Spring Boot(7)war方式打包发布
网友评论