Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改默认EL表达式解析 #485

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,9 @@ public class DsSpelExpressionProcessor extends DsProcessor {
* 对于默认不设置的情况下,从参数中取值的方式 #param1
* 设置指定模板 ParserContext.TEMPLATE_EXPRESSION 后的取值方式: #{#param1}
* issues: https://github.com/baomidou/dynamic-datasource-spring-boot-starter/issues/199
* issues: https://github.com/baomidou/dynamic-datasource-spring-boot-starter/issues/485
*/
private ParserContext parserContext = new ParserContext() {

@Override
public boolean isTemplate() {
return false;
}

@Override
public String getExpressionPrefix() {
return null;
}

@Override
public String getExpressionSuffix() {
return null;
}
};
private ParserContext parserContext = ParserContext.TEMPLATE_EXPRESSION;
private BeanResolver beanResolver;

@Override
Expand All @@ -82,8 +67,7 @@ public String doDetermineDatasource(MethodInvocation invocation, String key) {
ExpressionRootObject rootObject = new ExpressionRootObject(method, arguments, invocation.getThis());
StandardEvaluationContext context = new MethodBasedEvaluationContext(rootObject, method, arguments, NAME_DISCOVERER);
context.setBeanResolver(beanResolver);
final Object value = PARSER.parseExpression(key, parserContext).getValue(context);
return value == null ? null : value.toString();
return PARSER.parseExpression(key, parserContext).getValue(context, String.class);
}

/**
Expand Down