如何调用名称中带有分隔符的bean进行流动

How to call the bean with the separator in the name to flow

我有一颗豆子

<bean name="api.HelloWorld" class="ru.example.api.HelloWorld"/>

当你在流程中调用时我得到一个错误。

<evaluate expression="api.HelloWorld.test()"/>

如何调用?

如果你使用的是 SpEL,你可以使用这个:

<evaluate expression="@'api.HelloWorld'.test()"/>

如果您使用的是 OGNL 或 jboss-el,我认为除了使用实用程序 class 之外别无他法,如下所示:

@Component
public class WebFlowUtil {

    @Autowired
    private ApplicationContext applicationContext;

    public Object getBean(String beanName) {
        return applicationContext.getBean(beanName);
    }
}

然后使用:

<evaluate expression="webFlowUtil.getBean('api.HelloWorld').test()"/>