Spring App Error: EL1008E
Spring App Error: EL1008E
我一直致力于 Spring 集成项目,使用企业集成模式来使用 MQ 消息,进行一些处理,然后将它们写入另一个队列。
我的问题看起来与 this one 非常相似,但是接受的答案并没有为我解决。
收到来自外部网络服务的响应后,我的 @Cacheable
@Component
class returns 正文为 ArrayList
。我收到以下错误:
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 1): Property or field 'valid' cannot be found on object of type 'java.util.ArrayList' - maybe not public?
我认为这是冒犯性的 class:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.curator.x.discovery.ServiceCache;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@Component
public class DirectoryRepo {
@Autowired
private CacheManager cacheManager;
@Autowired
private ServiceCache<ServiceDetail> directoryServiceCache;
@Autowired
private RestTemplate restTemplate;
private ArrayList<X> response;
private static final Logger logger = LogManager.getLogger();
@Cacheable(value = "X", unless = "!#result.valid")
public ArrayList<X> checkForX(String a,
String b, String c, String d) {
try {
//code omitted
HttpHeaders headers = new HttpHeaders();
headers.add("token", service.getPayload().getToken());
ResponseEntity<X[]> responseEntity = restTemplate
.exchange(request, HttpMethod.GET, new HttpEntity<>(
headers), X[].class);
if (responseEntity != null && responseEntity.hasBody()) {
response = new ArrayList<X>(Arrays.asList(responseEntity.getBody()));
return response;
} else {
logger.debug("received unexpected responseEntity: {}",
responseEntity);
}
} catch (RestClientException e) {
logger.error("failed to get X - {}",
e.getMessage(), e);
}
throw new ServiceException(
"failed to get X - Directory service unavailable");
}
public ArrayList<X> getResponse() {
return this.response;
}
/**
* Clears out all entries from the X cache.
*/
@CacheEvict(value = "X", allEntries = true)
public void clearXCache() {
logger.trace("cacheManager:{}", cacheManager);
}
}
如您所见,我已经尝试设置public getter方法,但仍然出现异常:
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 1): Property or field 'valid' cannot be found on object of type 'java.util.ArrayList' - maybe not public
?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE
]
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access[=12=]0(PropertyOrFieldReference.java:46) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:374) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4
.RELEASE]
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:170) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.OperatorNot.getValueInternal(OperatorNot.java:47) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.OperatorNot.getValueInternal(OperatorNot.java:36) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.ExpressionEvaluator.unless(ExpressionEvaluator.java:123) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.canPutToCache(CacheAspectSupport.java:623) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELE
ASE]
at org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:675) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:361) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:302) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at somepackage.DirectoryRepo$$EnhancerBySpringCGLIB$$f7709589.checkForX(<generated>) ~[DirectoryRepo.class:?]
at somepackage.DirectoryService.getX(DirectoryService.java:66) ~[DirectoryService.class:?]
context.xml:
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="appName" path="/appName" copyXML="true">
</Context>
这个错误对我来说似乎很清楚。
不清楚您要做什么。 #result
变量是对...呃... result of calling the method
的引用 - 即 ArrayList
.
ArrayList
没有 isValid()
或 getValid()
方法。
The documentation about Conditional Caching 描述了您可以使用哪些变量。
As you can see I have tried setting a public getter method
我没有看到任何这样的东西。
您可以执行 result.size() > 0
、a != 'foo'
等操作。
我一直致力于 Spring 集成项目,使用企业集成模式来使用 MQ 消息,进行一些处理,然后将它们写入另一个队列。
我的问题看起来与 this one 非常相似,但是接受的答案并没有为我解决。
收到来自外部网络服务的响应后,我的 @Cacheable
@Component
class returns 正文为 ArrayList
。我收到以下错误:
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 1): Property or field 'valid' cannot be found on object of type 'java.util.ArrayList' - maybe not public?
我认为这是冒犯性的 class:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.curator.x.discovery.ServiceCache;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@Component
public class DirectoryRepo {
@Autowired
private CacheManager cacheManager;
@Autowired
private ServiceCache<ServiceDetail> directoryServiceCache;
@Autowired
private RestTemplate restTemplate;
private ArrayList<X> response;
private static final Logger logger = LogManager.getLogger();
@Cacheable(value = "X", unless = "!#result.valid")
public ArrayList<X> checkForX(String a,
String b, String c, String d) {
try {
//code omitted
HttpHeaders headers = new HttpHeaders();
headers.add("token", service.getPayload().getToken());
ResponseEntity<X[]> responseEntity = restTemplate
.exchange(request, HttpMethod.GET, new HttpEntity<>(
headers), X[].class);
if (responseEntity != null && responseEntity.hasBody()) {
response = new ArrayList<X>(Arrays.asList(responseEntity.getBody()));
return response;
} else {
logger.debug("received unexpected responseEntity: {}",
responseEntity);
}
} catch (RestClientException e) {
logger.error("failed to get X - {}",
e.getMessage(), e);
}
throw new ServiceException(
"failed to get X - Directory service unavailable");
}
public ArrayList<X> getResponse() {
return this.response;
}
/**
* Clears out all entries from the X cache.
*/
@CacheEvict(value = "X", allEntries = true)
public void clearXCache() {
logger.trace("cacheManager:{}", cacheManager);
}
}
如您所见,我已经尝试设置public getter方法,但仍然出现异常:
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 1): Property or field 'valid' cannot be found on object of type 'java.util.ArrayList' - maybe not public
?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE
]
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access[=12=]0(PropertyOrFieldReference.java:46) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:374) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4
.RELEASE]
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:170) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.OperatorNot.getValueInternal(OperatorNot.java:47) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.OperatorNot.getValueInternal(OperatorNot.java:36) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.ExpressionEvaluator.unless(ExpressionEvaluator.java:123) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.canPutToCache(CacheAspectSupport.java:623) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELE
ASE]
at org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:675) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:361) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:302) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at somepackage.DirectoryRepo$$EnhancerBySpringCGLIB$$f7709589.checkForX(<generated>) ~[DirectoryRepo.class:?]
at somepackage.DirectoryService.getX(DirectoryService.java:66) ~[DirectoryService.class:?]
context.xml:
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="appName" path="/appName" copyXML="true">
</Context>
这个错误对我来说似乎很清楚。
不清楚您要做什么。 #result
变量是对...呃... result of calling the method
的引用 - 即 ArrayList
.
ArrayList
没有 isValid()
或 getValid()
方法。
The documentation about Conditional Caching 描述了您可以使用哪些变量。
As you can see I have tried setting a public getter method
我没有看到任何这样的东西。
您可以执行 result.size() > 0
、a != 'foo'
等操作。