为什么 java bean 在构建端点时没有转换为 camel IdempotentRepository?

Why java bean is not converted to camel IdempotentRepository when building the endpoint?

我试过这个解决方案,但我的实施似乎不起作用:How to access Default Idempotent Repository map from java dsl?

@Bean
@Scope("prototype")
public static IdempotentRepository<String> getMemoryCache() {
    return new MemoryIdempotentRepository();
}

然后我尝试在我的 uri 中引用它,它抛出一个异常:

java.lang.IllegalArgumentException: Could not find a suitable setter for property: idempotentRepository as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.spi.IdempotentRepository with value #getMemoryCache()

.. 我为构建 uri 做了什么:

URIBuilder builder = _INSTANCE.getSourceFolderEndpointUriBuilder(exchange);
builder.setScheme("file");
builder.addParameter("recursive", "true");
builder.addParameter("readLock", "none");
builder.addParameter("idempotentRepository", "#getMemoryCache()");

我解决了, bean 必须在配置 class 中,然后引用 bean 它不应该有括号。

builder.addParameter("idempotentRepository", "#getMemoryCache");