Why can't we use @Cacheable with static method in spring with ehcache?

I am new to Spring and read that we cannot use @Cacheablewith static methodbut cannot understand why we cannot use, so can anyone explain so that a beginner can easily understand? Can we use the static method to extract database table? I did the static methodwhole service layerDAO method , so what is it thread-safe?

+4
source share
2 answers

Spring aspect concept

Developing my comment:

" . Spring - () . Java ."

Spring , (, Spring ).

, static , Spring ( , Spring)

+9

, .

- @Cacheable, Spring - bean, , bean. , :

@Inject
private MyBean myBean;
...
myBean.myMethod("foo");

MyBean myMethod() @Cacheable, MyBean , , -, MyBean.myMethod() .

Proxys , . @Cacheable .

+2

All Articles