Springboot打包为war包,部署tomcat

1、修改pom.xml文件将默认的jar方式改为war:

2、排除内置的Tomcat容器: 

添加依赖

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <!--打包的时候可以不用包进去,别的设施会提供。事实上该依赖理论上可以参与编译,测试,运行等周期。
                相当于compile,但是打包阶段做了exclude操作-->
            <scope>provided</scope>
        </dependency>

3、修改启动类,启动类继承SpringBootServletInitializer实现configure:

   @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringBootMainClass.class);
    }

4、然后maven->clean->install->package

5、将打包好的war包放入服务器tomcat的webapps下 

6、修改server.xml文件

添加以下内容:docBase 为war包名称

 <Context docBase="lee" path="/" reloadable="true" privileged="true"/>

7、启动tomcat,ip+端口访问项目。 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值