Method with @Cacheable is not working as expected in Spring

时间:2016-08-31 17:17:30

标签: java spring caching

I am trying to cache List in a Class as follows:

Class Person{
     @Autowired
     PersonService personService;
      .
      .
      .
      .
     @Cacheable("allStrings")
     public List<Strings> getAllStrings(){
        return personService.getStrings();

     } 


}

personService has getStrings() which will return all required strings. Eventhough I made getAllStrings() in Person class as Cacheable , cache is not created.

Is it because of proxy? How can I made above method cache without caching getStrings() in service?

Can't @Cacheable can't create cache if method is getting data from other service?

0 个答案:

没有答案