2017-02-17 83 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」的身份在控制器中扮演魅力。