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

时间:2017-08-10 15:17:28

标签: java spring apache-camel javabeans

我已尝试过此解决方案,但我的实施似乎不起作用: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()");

1 个答案:

答案 0 :(得分:0)

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

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