创建名为'loadTimeWeaver'的bean时出错

时间:2017-02-08 11:47:44

标签: java spring aop aspectj

我正在使用Maven运行集成测试,我的pom文件看起来像

<plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <runOrder>alphabetical</runOrder>
                    <skipTests>false</skipTests>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire.version}</version>
                <configuration>
                    <forkMode>once</forkMode>
                    <argLine>
                        -javaagent:${basedir}/target/spring-instrument-${spring.version}.jar
                    </argLine>
                    <!--<useSystemClassloader>true</useSystemClassloader>-->
                </configuration>
            </plugin>
        </plugins>

我有这个Spring.context conf

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:camel="http://camel.apache.org/schema/spring" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
                            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                            http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
                            http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">


    <context:load-time-weaver />

    <import resource="classpath*:coreAkkaContext.xml" />


</beans>    

当我尝试使用

初始化我的所有bean时
final GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext(resourceLocations );

我收到了例外

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [org.apache.maven.surefire.booter.IsolatedClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar

所以不知何故,测试不通过我传递给代理商的确定的配置

maven命令是

mvn clean test-compile failsafe:integration-test -DforkMode=never

任何想法都错了吗?

问候。

0 个答案:

没有答案