@Repository上的Spring @cacheable实现了接口 - '没有合格的bean ...'

时间:2017-02-17 10:04:39

标签: java spring caching

我使用Java 8和spring boot starter 1.3.0

我已经设置了一个缓存,它适用于使用@Repository注释的类。

我做了一次' ..实施IArgh {...'在课堂上,我的春季启动应用程序无法再加载。

这是能够使用缓存功能的类:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)\.html$ ilan.php?ilan=$1 

- 无论何时我使用带有' ..实现的类......',它都会中断,弹出启动应用程序会失败     说它无法注入' ArghRepo'它需要的任何地方。

// this 'works', i.e. application loads and triggers the cache on subsequent 
// requests

// File: ArghRepo.java
@Repository
public class ArghRepo {

    @Cacheable(value = "test", cacheManager = "springCM")
    public String testString(String test) {
        System.out.println("Cache is not hit: " + test);
        return test;
    }
}

1 个答案:

答案 0 :(得分:0)

'Homecontroller.java'中的@Autowired变量使用了ArghRepo类,而不是IArgh接口。

当我从“ArghRepo arghRepo”改变它时在控制器中的“IArgh arghRepo”它作为一种魅力。