存储库的自定义实现 Spring-Data-Cassandra

Custom Implementation of Repositories Spring-Data-Cassandra

我正在尝试使用 spring-data-cassandra 自定义存储库实现。我正在使用 spring-data-cassandra 1.5.M1。问题是自定义实现方法没有被执行。

下面是代码片段。

public interface JobRepositoryCustom{
   public Job getJobById(String id );
}

@Component
public class JobRepositoryCustomImpl implements JobRepositoryCustom{
    @Autowired
    CassandraOperations template; 

    public Job getJobById(String job ) {


        System.out.println("Some custom implementation");
        return job;
    }
}

public interface JobRepository extends TypedIdCassandraRepository<Job,String>, JobRepositoryCustom {

}

同样的驱动程序如下

@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class);
    }
    @Bean
    public CommandLineRunner demo( JobRepository repository) {
        Job job = new Job();
        job.setId("1817086421");
        job.setDescription("My job2 description");
        job.setOneMoreField("Just a new field");
        job.setTitle("Technical  Engineer job");
        repository.save(job);
        //The getJobById is custom method declared in JobRepositoryCustom
        repository.getJobById("My String");
        System.out.println("This after the  job");
        System.out.println("repository = [" + repository+ "]");
        return  null;
    }
}

我是否遗漏了什么?

将 JobRepositoryCustomImpl 重命名为 JobRepositoryImpl:

这是我的代码中的一个示例:

public interface ProductRepository extends JpaRepository<Product, Long>, ProductRepositoryCustom {

}



interface ProductRepositoryCustom {
    public String anyFunction();
}

@Repository
class ProductRepositoryImpl implements ProductRepositoryCustom {
    @Override
    public String anyFunction(){
         return "Hello";
    }
}