mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2026-05-29 18:57:11 +08:00
修复AI SPI classloader找不到实现问题(issue#4241@Github)
This commit is contained in:
@@ -36,6 +36,10 @@ public class AIServiceFactory {
|
||||
|
||||
// 加载所有 AIModelProvider 实现类
|
||||
static {
|
||||
for (final AIServiceProvider provider : ServiceLoaderUtil.load(AIServiceProvider.class)) {
|
||||
providers.putIfAbsent(provider.getServiceName().toLowerCase(), provider);
|
||||
}
|
||||
// issue#4241@github,多线程和Spring环境下可能导致SPI文件找不到问题
|
||||
for (final AIServiceProvider provider : ServiceLoaderUtil.load(AIServiceProvider.class, AIServiceProvider.class.getClassLoader())) {
|
||||
providers.putIfAbsent(provider.getServiceName().toLowerCase(), provider);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ public class AIConfigRegistry {
|
||||
|
||||
// 加载所有 AIConfig 实现类
|
||||
static {
|
||||
for (final AIConfig config : ServiceLoaderUtil.load(AIConfig.class)) {
|
||||
configClasses.putIfAbsent(config.getModelName().toLowerCase(), config.getClass());
|
||||
}
|
||||
// issue#4241@github,多线程和Spring环境下可能导致SPI文件找不到问题
|
||||
for (final AIConfig config : ServiceLoaderUtil.load(AIConfig.class, AIConfig.class.getClassLoader())) {
|
||||
configClasses.putIfAbsent(config.getModelName().toLowerCase(), config.getClass());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user