SpringBoot microservice project build war package deployment exclude specified jar

1. Build the war package to deploy the SpringBoot project

How to deploy the springboot project architecture war package to tomcat

Springboot is deployed to Tomcat and can be accessed without the project name

Second, build the war package
2.1. Scope of application

Suitable for SpringBoot/SpringCloud/SpringCloudAlibaba microservices/distributed projects

2.2. Building the war package

Set the packaging format in the pom that builds the packaged project

step 1:

<packaging>war</packaging>

Step 2:
Create a Web initialization class at the same level as the project startup class and
insert image description here
copy it directly

package com.gblfy.xe;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Configuration;

/**
 * know Web程序启动类
 *
 * @author gblfy
 * @Date 2019/11/21 9:43
 */
@Configuration
public class ServletInitializer extends SpringBootServletInitializer {
    
    

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    
    
        return builder.sources(RuoYiSystemApplication.class);
    }
    //这个类继承至SpringBoorServletInitializer,并覆盖了其configuer方法
}


Note: XeApplication needs to be replaced with the name of the startup class

3. Deployment excludes the specified jar
3.1. Download exclusion plugins

insert image description here
Restart the project, the plugin takes effect

3.2. Search deployment excludes specified jars

insert image description here

3.3. Exclude the deployment of the specified jar

Click Exclude to exclude
insert image description here
this is the dependency icon after exclusion
insert image description here

3.4. Authentication

In order to verify whether the dependencies of the specified tomcat are included in the dependencies, let's track the source code
, select the dependencies, hold down the ctrl key + the left mouse button and click to enter
insert image description here

ctrl+f search for keywords to search
insert image description here
Here, it has been excluded since then!

3.5. Core Concept

Find the specified project, click the pom double-click, select the plug-in, exclude dependencies, and verify the effect of the source code

Guess you like

Origin blog.csdn.net/weixin_40816738/article/details/123655722