springboot labeled as war package and carry third-party jar package

1. The modified embodiment is packaged war

    <packaging>war</packaging>

2. Add the jar to rely on third-party pom

    My third-party jar package in the lib directory under resoueces (directory may be other paths, pom lead pack to the right)
    <dependency>
    <groupId>otc</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/otc-commons-logging-1.2.jar</systemPath>
</dependency>

3. exclude built-in Tomcat (two ways available)

Method 1: Add dependence

<Dependency> <-! Run the scope commented, when packaged with the scope to be ->
<! - packed bag when you can not go in, other facilities will be provided. In fact this dependency cycle theory can participate compile, test, run and so on.
        Equivalent to compile, but do exclude packing stage operation ->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

Second way: negative spring-boot-starter-web in Tomcat

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

4. Add plugin

<plugin>
<!--<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArguments>
<bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<Resource>
<Directory> the src / main / Resources / lib </ Directory>
<The targetPath> the WEB-INF / lib / </ The targetPath>
<Includes>
<the include> ** / *. JAR </ the include>
</ Includes>
</ Resource>
</ Resources page at http://windows.microsoft.com/windows2000/reskit/webresources>
</ the Configuration>
</ plugin>

this springboot carry third-party jar package labeled as the end of the war package.

Inadequacies also please correct me.

Guess you like

Origin www.cnblogs.com/wlv1314/p/12127887.html