java - 比较 SpEL 中的枚举

在 Spring @Cacheable注释我想指定一个 unless条件。

但是我的返回值既不是原始类型也不是 Java bean,而是一个枚举。

如何与 SpEL 中的另一个 Enum(Spring 表达式语言)比较相等性?

最佳答案

#result == T(fully.qualified.path.to.AnEnum).A_VALUE

引用 here :

You can use the special T operator to specify an instance of java.lang.Class (the type).

https://stackoverflow.com/questions/21806298/

相关文章:

java - 如何在spring mvc中使用带有freemarker的消息?

spring - 配置多个数据源后无法设置JPA命名策略(Spring 1.4.1/Hibernat

java - @ControllerAdvice 在处理异常方面比 @ExceptionHandle

java - 我无法使用断点进行调试

java - 为什么 Spring 的 jdbcTemplate.batchUpdate() 这么慢

java - 使用 restAssured 测试 Spring Boot Rest 应用程序

java - 在 Spring Boot 中读取环境变量

java - AspectJ 表达式在切入点错误中给出正式的未绑定(bind)

java - 为什么来自 Spring 的 BCryptPasswordEncoder 为相同的输入

java - 无法将 boolean 值设置为 null