我有一个带有一组命名查询的 Java 类(实体)。当 Spring 尝试注入相关 bean 时,它没有找到查询之一。
例如:
@NamedQueries({
@NamedQuery(name = "Query1", query = "..."),
@NamedQuery(name = "Query2", query = "..."),
@NamedQuery(name = "Query3", query = "..."),
@NamedQuery(name = "Query4", query = "..."),
@NamedQuery(name = "Query5", query = "...")
})
当 Spring 尝试注入 bean 时,我得到:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'myBean': Injection of resource methods failed;nested exception is
java.lang.IllegalArgumentException: Named query not found: Query3 at ...
我确定查询是正确的(它们的所有单元测试都通过了)。
有人知道它的根本原因吗?