Reputation: 878
I have a SpringbootApplication that provides a REST API, let's call it fetchPrediction
.
This fetchPrediction
API uses some classes defined inside a JAR file, which is a JNI.
My application compiles and starts, however, if I call the fetchPrediction
API it fails.
When I do jar -xvf on the created jar after mvn clean install
, I do not see the classes that should be picked up by including the jar dependency.
Also, when I try to run the Jar file I see ClassNotDefinedException
for the classes inside the JAR.
How can I do this properly?
Currently I am importing the JAR dependency as follows:
<dependency>
<groupId>jarcom.jarlib</groupId>
<artifactId>jarname</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/jarname.jar</systemPath>
</dependency>
Upvotes: 0
Views: 253
Reputation: 97447
In an spring boot application you usually do not have JNI parts. Furthermore the spring-boot-maven-plugin by default does not include dependencies with <scope>system</scope>
that's the reason why you do not see the jar file in the resulting jar.
You have to have to configure the spring-boot-maven-plugin and set the includeSystemScope to true
as described in the docs for the plugin.
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.4.RELEASE</version>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</execution>
</executions>
...
</plugin>
...
</plugins>
...
</build>
...
</project>
Upvotes: 1