问题
使用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>
翻译自: https://mkyong.com/spring3/cglib-is-required-to-process-configuration-classes/