Basically either need to put your DLL file's path in Windows' %PATH%
variable, or explicitly set it using Maven's Surefire plugin as explained in this post since you are getting this error in TEST phase.
how to specify dll file as dependency to maven runtime
-
06-10-2022 - |
Pergunta
When running my test cases (using mvn test), my test case fails; because one of the library I use internally calls a dll file. My test case fails, saying the file is not in java library path. Below is my pom file and test output (from mvn test). i copied the dll file to src/test/resource but it didnt help
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${artifactId}-${version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<!-- <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> -->
<testSourceDirectory>src/test</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
</plugin>
</plugins>
</pluginManagement>
T E S T S
1 [main] DEBUG Sigar - no sigar-amd64-winnt.dll in java.library.path
org.hyperic.sigar.SigarException: no sigar-amd64-winnt.dll in java.library.path
at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172)
at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
at org.hyperic.sigar.cmd.Shell.<init>(Shell.java:50)
at org.hyperic.sigar.cmd.SigarCommandBase.<init>(SigarCommandBase.java:75)
at com.harmonia.cbm.dataaquisition.pal.CpuInfoTest.<init>(CpuInfoTest.java:41)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.maven.surefire.junit.PojoTestSet.<init>(PojoTestSet.java:63)
at rg.apache.maven.surefire.junit.JUnit3Provider.createTestSet(JUnit3Provider.java:117)
at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(Fork
edBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow