2017-02-17 1 views
0

내가 자바 (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'를 주사 할 수 없었습니다. 'Homecontroller.java'에서

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

내 @Autowired 변수는 ArghRepo 클래스가 아닌 인터페이스 IArgh을 사용했다.

"ArghRepo arghRepo"에서 변경했을 때 "IArgh arghRepo"로 컨트롤러에서 작동했습니다.

관련 문제