I have a default jersey project, downloaded from https://start.spring.io/ to which I added a lib folder and in it a library compiled in c ++ to be called via JNI. In Eclipse add the "lib" directory to the classpath and it runs perfectly through the "Java Application" option. When trying to run direct with the maven command mvn spring-boot:run
, it gives me error when trying to load the library. my pom file is:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ec.com.extractdatacom</groupId>
<artifactId>RestExtractDataDicom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RestExtractDataDicom</name>
<description>Proyecto para procesar archivos dicom</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.opencsv/opencsv -->
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<version>4.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${project.basedir}/lib</additionalClasspathElement>
</additionalClasspathElements>
<systemPropertyVariables>
<propertyName>java.library.path</propertyName>
<buildDirectory>${project.basedir}/lib</buildDirectory>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
The error, only when mvn spring-boot:run
is:
java.lang.UnsatisfiedLinkError: no ExtractDataDicom in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) ~[na:1.8.0_121]
at java.lang.Runtime.loadLibrary0(Runtime.java:870) ~[na:1.8.0_121]
at java.lang.System.loadLibrary(System.java:1122) ~[na:1.8.0_121]
at ec.com.extractdatacom.jni.ExtractDataDicom.<clinit>(ExtractDataDicom.java:12) ~[classes/:na]