mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
Merge pull request #127 from 2han9wen71an/main
修复OSGI环境ClassLoader获取不到类
This commit is contained in:
commit
3b92ef27ba
@ -44,7 +44,7 @@ public class LambdaUtil {
|
|||||||
|
|
||||||
public static <T> Class<?> getImplClass(LambdaGetter<T> getter) {
|
public static <T> Class<?> getImplClass(LambdaGetter<T> getter) {
|
||||||
SerializedLambda lambda = getSerializedLambda(getter);
|
SerializedLambda lambda = getSerializedLambda(getter);
|
||||||
return getImplClass(lambda);
|
return getImplClass(lambda, getter.getClass().getClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,9 +56,10 @@ public class LambdaUtil {
|
|||||||
|
|
||||||
|
|
||||||
public static <T> QueryColumn getQueryColumn(LambdaGetter<T> getter) {
|
public static <T> QueryColumn getQueryColumn(LambdaGetter<T> getter) {
|
||||||
|
ClassLoader classLoader = getter.getClass().getClassLoader();
|
||||||
SerializedLambda lambda = getSerializedLambda(getter);
|
SerializedLambda lambda = getSerializedLambda(getter);
|
||||||
String methodName = lambda.getImplMethodName();
|
String methodName = lambda.getImplMethodName();
|
||||||
Class<?> entityClass = getImplClass(lambda);
|
Class<?> entityClass = getImplClass(lambda, classLoader);
|
||||||
TableInfo tableInfo = TableInfoFactory.ofEntityClass(entityClass);
|
TableInfo tableInfo = TableInfoFactory.ofEntityClass(entityClass);
|
||||||
return tableInfo.getQueryColumnByProperty(PropertyNamer.methodToProperty(methodName));
|
return tableInfo.getQueryColumnByProperty(PropertyNamer.methodToProperty(methodName));
|
||||||
}
|
}
|
||||||
@ -77,11 +78,11 @@ public class LambdaUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Class<?> getImplClass(SerializedLambda lambda) {
|
private static Class<?> getImplClass(SerializedLambda lambda, ClassLoader classLoader) {
|
||||||
String implClass = getImplClassName(lambda);
|
String implClass = getImplClassName(lambda);
|
||||||
return MapUtil.computeIfAbsent(classMap, implClass, s -> {
|
return MapUtil.computeIfAbsent(classMap, implClass, s -> {
|
||||||
try {
|
try {
|
||||||
return Class.forName(s.replace("/", "."));
|
return Class.forName(s.replace("/", "."), true, classLoader);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user