gpt4 book ai didi

Java:创建名称为 'loadTimeWeaver' 的 bean 时出错?

转载 作者:行者123 更新时间:2023-11-30 08:52:38 35 4
gpt4 key购买 nike

我目前正在做一个 Maven 项目,但每次我尝试部署我的 war 时,我都会遇到以下异常:

ERROR [DispatcherPortlet:276] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.weaving.AspectJWeavingEnabler#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed;  nested exception is java.lang.IllegalStateException: ClassLoader [org.apache.catalina.loader.WebappClassLoader] does NOT provide an 'addTransformer(ClassFileTransforme r)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1097)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:661)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:356)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:294)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:268)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:120)

我根本不明白当我把一切都准备好时为什么会出现这个错误。请检查我在 POM.xml 中的声明

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4</version>
<configuration>
<forkMode>once</forkMode>
<argLine>
-javaagent:"path\spring-instrument-3.1.0.RELEASE.jar"
</argLine>
<useSystemClassloader>true</useSystemClassloader>
</configuration>
</plugin>

请指导。

最佳答案

如果您正在使用 tomcat bundle 并在 Tomcat 中启用 load-time-weaving 添加 Spring Instrument Tomcat到 Tomcat 的 lib 目录和 context.xml 中的以下内容,位于您的 tomcat 的 META-INF 目录中:

<Context path="/test">
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
</Context>

引用Spring Docs在 tomcat 的配置上。

注意:tomcat 的配置因版本而异。

关于Java:创建名称为 'loadTimeWeaver' 的 bean 时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30118798/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com