idea—springboot多模块打包流程

在我们日常的程序开发中,项目打包是一个必不可少的环节,很多小型公司或者传统公司,没有专业的运维团队和测试人员,所以项目的打包上线的活,毫无疑问就成为了我们开发人员的工作。

idea

idea不用多说,是目前最常见也是最普及的java开发工具;我们选择打包的项目是spring boot,多模块项目。

第一步;

因为springboot内置了tomcat,所以我们首先要将springboot的内置tomcat给清除(禁用)掉。
在这里插入图片描述
在这个依赖上面加入

<exclusions>
   <exclusion>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-tomcat</artifactId>
   </exclusion>
</exclusions>

这样的话就将springboot内置的tomcat给禁用掉了;

第二步;

启动类继承SpringBootServletInitializer类,重写configure方法;
在这里插入图片描述

@SpringBootApplication
@EnableAsync
@ServletComponentScan
public class app extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(app.class);
    }
    public static void main(String[] args) {
        SpringApplication.run(app.class,args);
    }
}

上面三个注解,一个是扫描包,一个是开器多线程,一个是开起过滤器

第三步;

在这里插入图片描述
选中root(父级模块)项目,点击package进行打包;

第四步;

在这里插入图片描述
这个时候就可以在target文件夹下看到war包了;

第五步;

注意:如果你是要打成war包的话,需要在模块下面加上标识;
在这里插入图片描述
因为idea创建maven项目,默认是jar类型的

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章