what reasons are there to use interfaces (Java EE or Spring and JPA)

后端 未结 3 1676
深忆病人
深忆病人 2020-12-08 12:14

Most of the J2EE(Spring and JPA) classes are designed with interfaces. Except for inheritance, are there any technical reasons for this? Like dynamic proxy

3条回答
  •  独厮守ぢ
    2020-12-08 13:01

    Because you have mentioned Spring explicite.

    Spring AOP can be used in different configurations. The default one uses java dynamic proxies (java.lang.reflect.Proxy). This can be only applied to Interfaces

    Spring AOP defaults to using standard J2SE dynamic proxies for AOP proxies. This enables any interface (or set of interfaces) to be proxied.

    @see Spring Reference Chapter 7.1.3 AOP Proxies @see Dynamic Proxy Classes

提交回复
热议问题