I am using spring-boot and maven. I managed to overwrite java.library.path
in jvmArguments
tag. However, I would like to append a path to java.library.path
. Can I do this in the pom.xml
file?
-
you can add -Djava.library.path to your MAVEN_OPTS environment variable.– AvinashMar 10, 2017 at 0:18
-
Is it possible to modify this variable in pom.xml ?– user7315995Mar 10, 2017 at 9:53
-
You can try solution mentioned here : stackoverflow.com/questions/23672992/…– AvinashMar 10, 2017 at 10:08
1 Answer
In production: in the pom edit the spring-boot-maven-plugin's , add true -Djava.library.path=./libs This will add the parameter to the startup script, if you have a self executing spring-boot. obviously, if you're running inside container (e.g. tomcat), you have to edit the startup parameters there.
For integration testing use the maven-surefire-plugin, and set this here:
<configuration>
<environmentVariables>
<LD_LIBRARY_PATH>${project.basedir}/libs</LD_LIBRARY_PATH>
</environmentVariables>
<systemPropertyVariables>
<java.library.path>./libs</java.library.path>
</systemPropertyVariables>
</configuration>
taken from http://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html
Also the LD_LIBRARY_PATH is set here, so that on linux-systems dependent libraries can be loaded. If you only have one library, you don't need the <environmentVariables>
part.
BTW: If you add the java.library.path to the maven commandline, this won't work, because surefire fires up its own jvm.