Tomcat solves the deploy web project containing the file so of the linux dynamic link library without restarting tomcat

This problem has troubled me for a long time, and I still don’t understand its principle, but fortunately, I have successfully solved this problem. There are answers on the Internet, but it is relatively simple. Hope to help more people.

1. The libTest.so file is placed in the java.library.path directory of the linux system (System.getProperty( "java.library.pah") can be obtained )

2. Create a new java project that loads soload

static {

String soPath="Test";

System.loadLibrary(soPath);

}

Note that there is no lib prefix and so suffix here

publicnativeintTest(int x,int y);   

Package the file as a jar package soload.jar , and then include the jar package into the maven -structured web project

<dependency>

<groupId>com.baidu.java</groupId><!--自定义 -->  

<artifactId>soload</artifactId><!--自定义 -->    

< version > 1.0 </ version > <!--customize--> 

< scope > system </ scope > <!--system, similar to provided, after you need to explicitly provide the dependent jar, Maven will not look it up in the Repository --> 

< systemPath > ${ basedir }/ lib /soload.jar </ systemPath > <!-- under the lib folder under the project root directory --> 

</dependency>

There is no need to include the jar package into the war package here

1. Upload the soload.jar package to the ${tomcat}/server/lib directory , create it if there is no server/lib directory , and then modify server.loader=${catalina. base}/server/classes,${catalina.base}/server/lib/*.jar

shared.loader=${catalina.base}/server/classes,${catalina.base}/server/lib/*.jar

Note: server.loader and shared.loader are the same

Indicates that the jar package in the ${tomcat}/server/lib directory will be automatically loaded after tomcat is started

2. 将war包上传到webapp中,然后启动tomcat,当再次需要发布war项目时(没有修改soload.jar)直接将war包上传到webapp中,不需要重启tomcat



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325597806&siteId=291194637