宝塔部署War包的SpringBoot

宝塔部署War包的SpringBoot

Jammm
2020-12-04 / 0 评论 / 385 阅读 / 正在检测是否收录...

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
本文共 111 个字数,平均阅读时长 ≈ 1分钟
0

打赏

海报

正在生成.....

评论 (0)

取消