Spring 数据 JPA Spel - @Query 问题

Aru*_*unM 5 spring spring-el spring-data spring-data-jpa

我无法让 SPEL 和 Spring 数据 jpa 正常工作

以下是我的存储库

package eg.repository;
public interface MyEntityRepository extends JpaRepository<MyEntity, Long>,JpaSpecificationExecutor<MyEntity> {

    @Query("SELECT e FROM eg.domain.MyEntity e " +
            "WHERE e.title = :#{#filter.title}"
    )
    Page<MyEntity> list1(@Param("filter") MyFilter filter,Pageable pageable);
}
Run Code Online (Sandbox Code Playgroud)

过滤组件

package eg.service;

import org.springframework.stereotype.Component;

@Component("filter")
public class MyFilter {

    public String titleFilter() {
        return "%title%";
    }
    private String title = "title title1";
    public Long[] idFilter() {
        return new Long[] {
                1L, 2L
        };
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是我的实体

package eg.domain;
@Entity
public class MyEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "title")
    private String title;
    ......
}
Run Code Online (Sandbox Code Playgroud)

主类

LOG.info("Application initialized " + annotationConfigApplicationContext);
        MyEntityRepository myEntityRepository =
                    (MyEntityRepository) annotationConfigApplicationContext.getBean(MyEntityRepository.class);
        MyFilter filter = annotationConfigApplicationContext.getBean(MyFilter.class);
        PageRequest pageRequest = new PageRequest(0, 5);
        Page<MyEntity> page = myEntityRepository.list1(filter,pageRequest);
        List<MyEntity> entities= page.getContent();
        for(MyEntity entity: entities){
            System.out.println(entity.getId() + " TITLE " +  entity.getTitle());
        }
Run Code Online (Sandbox Code Playgroud)

以下是我得到的错误

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myEntityRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Using named parameters for method public abstract org.springframework.data.domain.Page eg.repository.MyEntityRepository.list1(eg.service.MyFilter,org.springframework.data.domain.Pageable) but parameter 'filter' not found in annotated query 'SELECT e FROM eg.domain.MyEntity e WHERE e.title = :#{#filter.title}'!
Run Code Online (Sandbox Code Playgroud)

Dip*_*Dam 0

private String title = "title title1";
Run Code Online (Sandbox Code Playgroud)

过滤器的标题是私有的,我看不到该属性的任何吸气剂。可能这就是问题所在。