Question
I have an external .jar that cannot be imported from public repositories using
pom.xml, it's sqljdbc41.jar
.
I can run the project locally from my IDE, and everything will work. I referenced the library after downloading it like so:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc41</artifactId>
<version>4.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/sqljdbc41.jar</systemPath>
</dependency>
When I run mvn clean package
to create my .jar file and try to run the
created .jar, a mistake will pop up, which mentions the SQL Server references
are not valid. I then extracted my .jar file and true enough, everything that
is referenced in the pom.xml
file properly gets downloaded and added,
however, my SQL Server does not.
I can, in a very hacky way* just manually add the sqljdbc41.jar
to my /lib
folder after it's been compiled as a .jar, and it'll work, however that seems
highly unoptimal. What would be a better approach?
*Opening the .jar file with Winrar, going to the /lib folder, manually selecting my sqljdbc41.jar
file, then make sure to select the No Compression option bottom left where Winrar gives you compression options, in case you find this by Google and no one answered.
Answer
you can set 'includeSystemScope' to true.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>