Build a jar package would include mssql-jdbc.jar in the BOOT-INF/lib directory. Build a war package would not include mssql-jdbc.jar in the WEB-INF/lib directory.

spring-boot version: 2.2.4.RELEASE

<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<!--  <packaging>jar</packaging> -->

<dependencies>
  <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>7.0.0</version>
        <scope>system</scope>
        <systemPath>lib/mssql-jdbc.jar</systemPath>
    </dependency>
</dependencies>

 <build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <includeSystemScope>true</includeSystemScope>
            </configuration>
        </plugin>
  </plugins>
<build>

Comment From: wilkinsona

Thanks for your patience while we found time to look at this.

I believe that this is working as designed. In a war file, system scope dependencies are packaged in WEB-INF/lib-provided. This means that they are found in the war file and placed on the classpath when run using java -jar but hidden from the container in a traditional deployment. This allows the executable archive to be completely self-contained while allowing the container in a traditional deployment to provide system-scope dependencies.

I don't think we have an integration test that covers system scope dependencies with war packaging. We can use this issue to add one.