我正在使用Spring3.1。战争不是用Maven建立的。这只是一种正常的身材。我的课堂道路上有下面的罐子。
antlr-runtime-3.0.1.jar
commons-logging-1.1.1.jar
org.apache.commons.logging.jar
org.springframework.aop-3.1.0.M2.jar
org.springframework.asm-3.1.0.M2.jar
org.springframework.aspects-3.1.0.M2.jar
org.springframework.beans-3.1.0.M2.jar
org.springframework.context-3.1.0.M2.jar
org.springframework.context.support-3.1.0.M2.jar
org.springframework.core-3.1.0.M2.jar
org.springframework.core-3.1.0.RELEASE.jar
org.springframework.core.jar
org.springframework.expression-3.1.0.M2.jar
spring-beans-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar我有下面的代码
@Configuration
public class AppConfig {
@Bean(name="helloBean")
public HelloWorld helloWorld()
{
return new HelloWorldImpl();
}
}当我运行main方法时,下面是异常
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 org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:297)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigurationClasses(ConfigurationClassPostProcessor.java:200)为了克服这一问题,如果我添加了cglib-2.1.jar,就会出现以下的异常。
java.lang.ClassNotFoundException: org.objectweb.asm.Type为了克服这个问题,如果我添加了asm3.1.jar,就会出现异常。
java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.如何克服我最初的异常-- CGLIB is required to process @Configuration classes ?
发布于 2013-08-14 06:58:46
战争不是用Maven建立的。这只是一种正常的构造
您的问题恰恰突出了为什么您应该使用Maven (或其他类似的依赖工具) --祝贺您以艰苦的方式学习事物。Java世界中的库通常有一个非常复杂的依赖树,Maven可以帮助您解决所有这些问题。
在您的例子中,如果您使用maven,您只需要包含cglib依赖项,它的所有传递依赖项(包括asm)都将为您解决。
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.0</version>
</dependency>发布于 2015-09-09 09:25:34
从Spring3.2开始,不再需要来添加cglib作为显式依赖项。
参考资料:消失了
对于那些想知道为什么他们的项目在没有cglib的情况下正常运行的人来说,这个答案,并来到这个页面搜索有关cglib作为我的信息。
发布于 2014-01-05 04:42:23
您的程序中需要CGLIB库。您可以使用Maven下载依赖项。
由gerrytan发布的xml。
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.0</version>
</dependency>如果不使用maven (或其他依赖项工具),可以从CGLIB HomePage下载库。
https://stackoverflow.com/questions/18224365
复制相似问题