springboot動態加載sigar

maven

<dependency>
            <groupId>com.github.cb372</groupId>
            <artifactId>metrics-sigar</artifactId>
            <version>0.2.2</version>
        </dependency>

native

<dependency>
            <groupId>org.fusesource</groupId>
            <artifactId>sigar</artifactId>
            <version>1.6.4</version>
            <classifier>native</classifier>
        </dependency>

解壓該jar包,拷貝so以及dylib文件到spring boot公共模塊工程的resources文件夾下git

加載so文件

  • 根據os.name獲取須要加載哪類so文件github

  • System.loadspring

static方法塊加載,在new Sigar以前加載maven

doc

相關文章
相關標籤/搜索