問題

Spring3 `@ Configuration`を使用して、以下のようなアプリケーション構成ファイルを作成します。

import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {

    @Bean
  //...

}

ただし、実行すると、次のエラーメッセージが表示されます。

org.springframework.context.support.AbstractApplicationContext prepareRefresh//...
Exception in thread "main" java.lang.IllegalStateException:
CGLIB is required to process @Configuration classes.
Either add CGLIB to the classpath or remove the following
@Configuration bean definitions:[appConfig]//...
at com.mkyong.core.App.main(App.java:12)

解決策

Spring 3で

@ Configuration`を使うには、手動で

CGLIB

ライブラリをインクルードする必要があります。単にMavenの

pom.xml`ファイルに宣言するだけです。

    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
    </dependency>