Add external library .jar to Spring boot .jar internal /lib

You could install the sqljdbc41.jar in your local repository :

mvn install:install-file -Dfile=path/to/sqljdbc41.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc41 -Dversion=4.1 -Dpackaging=jar

And then declare the dependency as a standard dependency :

<dependency>
   <groupId>com.microsoft.sqlserver</groupId>
   <artifactId>sqljdbc41</artifactId>
   <version>4.1</version>
</dependency>

If you use a remote artifact repository (nexus, archiva...) you also need to deploy the artifact on this repository. You can find more here : https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html


another way, you can put it into the resources folder, such as resources/lib/xxx.jar, then config the pom.xml like this:

<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc41</artifactId>
<version>4.1</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/lib/sqljdbc41.jar</systemPath>


you can set 'includeSystemScope' to true.

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