侧边栏壁纸
博主头像
Jammmの日常博主等级

行动起来,活在当下

  • 累计撰写 71 篇文章
  • 累计创建 47 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

宝塔部署War包的SpringBoot

Administrator
2020-12-04 / 0 评论 / 0 点赞 / 21 阅读 / 4085 字

1.调整pom.xml

加入war

<groupId>com.jam</groupId>
<artifactId>childrenmonitor</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> //说明打包成war包
<name>childrenmonitor</name>
<description>children Monitor and Control</description>

声明tomcat内置服务,不做为外部服务。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

2.添加Webapps目录

双击下面 【4】 点击OK

SpingBootWar1

添加web.xml

这里一定要注意:web.xml的目录需要更改成之前在scr\main下面创建的webapp目录

SpingBootWar2

SpingBootWar3

3.重写Application.java

继承SpringBootServletInitializer

添加下面代码:

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

3.1完整Applicaiton.java

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;


@SpringBootApplication
@MapperScan("com.jam.dao")
public class ChildrenmonitorApplication extends SpringBootServletInitializer {


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

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

}

4.部署

  1. 把war包放入服务器tomcat的webapps目录,自动解压。
  2. 添加网站,目录选择webapps自动解压的目录
  3. 在网站设置中开启tomcat
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区