我想使用cache
分配spring el
名称,但我将获得以下异常。
有没有办法使用cache
传递spring el
名称。
@Cacheable(value={"#p0"} ,key="#url", condition="#doCache")
public byte[] httpGetAsByteArray(String cacheRegion,String url,HttpHeaders headers, List<MediaType> acceptableMediaTypes, boolean doCache,boolean proxyRequest) throws HttpBeanException, AuthenticationFailedException {
//logic is here.
}
获得例外:
java.lang.IllegalArgumentException: Cannot find cache named '#p0' for Builder[public byte[] com.vodafone.global.vfstart.juno.http.integration.service.HttpIntegrationService.httpGetAsByteArray(java.lang.String,java.lang.String,org.springframework.http.HttpHeaders,java.util.List,boolean,boolean) throws ] caches=[#p0] | key='#url' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='#doCache' | unless='' | sync='false'
答案 0 :(得分:0)
在异常消息和@Cacheable
javadoc中,value
或等效的cacheNames
属性似乎不支持Spring EL。
您可以通过利用cacheResolver
attribute来实现您想要的目标。