2017-02-17 84 views
0

我使用Java 8,和春季开机启动1.3.0春@cacheable它实现接口 - “没有合格豆......”

我已经设置了缓存,其上标注的一类作品与@Repository。

一旦我在类上执行IArgh {...'我的弹簧引导应用程序不再能够加载。

下面是能够与高速缓存的功能类:

// 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; 
    } 
} 

- 每当我使用的类与“..implements ..”,它打破和弹簧启动应用程序失败 说它不能在需要的地方注入'ArghRepo'。

// this fails, and the application is not able to load, saying that it's not able to inject ArghRepo: 

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

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


// File: IArgh.java 
public interface IArgh { 
    String testString(String test); 
} 

回答

0

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

当我从“ArghRepo arghRepo”更改它时,以“IArgh arghRepo”的身份在控制器中扮演魅力。