pf4j简介及例子运行说明
所属分类 pf4j
浏览量 745
Java轻量级插件框架,可实现动态加载,执行,卸载外部插件(支持jar zip)
The current minimum Java version required to build PF4J should be 9, but the runtime Java version can be 8 since the artifact is a multi-release jar.
https://github.com/pf4j/pf4j/releases/tag/release-3.4.0
run-demo.sh
运行脚本需要修改下
mv pf4j-demo-app-*-SNAPSHOT.jar pf4j-demo.jar
改成
mv pf4j-demo-app-3.4.0.jar pf4j-demo.jar
jdk8 运行报错
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project pf4j: Fatal error compiling: 无效的标记: --release
Fatal error compiling: 无效的标记: --release
jdk11 ok
运行之前设置下 JAVA_HOME
export JAVA_HOME=/PATH/jdk11/Contents/Home
demo/app/target
pf4j-demo-app-3.4.0.zip
解压后目录结构
pf4j-demo-app-3.4.0.jar
lib
java-semver-0.9.0.jar
pf4j-3.4.0.jar
pf4j-demo-api-3.4.0.jar
...
semver
Semantic Versioning
https://semver.org/
demo-dist 目录结构
├── lib
│ ├── commons-lang-2.4.jar
│ ├── java-semver-0.9.0.jar
│ ├── log4j-api-2.13.1.jar
│ ├── log4j-core-2.13.1.jar
│ ├── log4j-slf4j-impl-2.13.1.jar
│ ├── pf4j-3.4.0.jar
│ ├── pf4j-demo-api-3.4.0.jar
│ └── slf4j-api-1.7.25.jar
├── pf4j-demo.jar
└── plugins
├── disabled.txt
├── enabled.txt
├── pf4j-demo-plugin1-3.4.0-all.jar
└── pf4j-demo-plugin2-3.4.0-all.jar
pf4j-demo-plugin1-3.4.0-all.jar 289281
pf4j-demo-plugin2-3.4.0-all.jar 3601
注意 plugin1 依赖了 apache commons-lang ,会把他一并打进去 ,因此打出来的jar包比较大
jar tvf pf4j-demo-plugin1-3.4.0-all.jar
demo-dist 目录下运行
java -jar pf4j-demo.jar
在jdk8 和 jdk11 运行ok
上一篇
下一篇
scala Option(null) 和 Some(null) 的区别
scala Option 小结
jdbc获取自增主键ID
pf4j 例子应用 类加载机制验证
Play2.6.x开始使用Akka HTTP作为默认服务后端
guice循环依赖处理