Spring AOPエラー:CGLIB2が利用できないため、ターゲットクラスをプロキシできません

Spring AOPエラー:CGLIB2が利用できないため、ターゲットクラスをプロキシできません

Spring AOPでは、「Cannot proxy target class because CGLIB2 is not available」エラーメッセージを回避するために、ビルドパスにcglibライブラリを含める必要があります。

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerServiceProxy': FactoryBean threw exception on object creation; nested exception is org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:127)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:91)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:217)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
    at com.example.common.App.main(App.java:14)
Caused by: org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
    at org.springframework.aop.framework.DefaultAopProxyFactory.createAopProxy(DefaultAopProxyFactory.java:67)
    at org.springframework.aop.framework.ProxyCreatorSupport.createAopProxy(ProxyCreatorSupport.java:106)
    at org.springframework.aop.framework.ProxyFactoryBean.getSingletonInstance(ProxyFactoryBean.java:317)
    at org.springframework.aop.framework.ProxyFactoryBean.getObject(ProxyFactoryBean.java:243)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:121)
    ... 9 more

溶液

以下からcglibライブラリをダウンロードできます。

1. Cglib公式ウェブサイト
http://cglib.sourceforge.net/

Mavenを使用している場合は、Maven依存関係のみを含めることができます。

    
    
        cglib
    cglib
    2.2