仅在Eclipse中? java.lang.NoSuchMethodError:org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh

时间:2015-01-30 15:21:53

标签: java eclipse spring junit

在Eclipse中,我发现我运行的任何包含@RunWith(SpringJUnit4ClassRunner.class)的JUnit测试都会出现以下错误。当我在命令提示符下运行测试时,它们运行正常。

我已经看到其他帖子表明Spring版本问题,但我似乎无法找到问题 - 我猜这是Eclipse配置问题?

我正在为Web开发人员使用Eclipse Java EE IDE。 版本:Luna Service Release 1(4.4.1) 构建ID:20140925-1800

错误记录

java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh(Lorg/springframework/beans/factory/annotation/InjectionMetadata;Ljava/lang/Class;)Z
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:368)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:323)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:830)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:493)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:378)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:161)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    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:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
    at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
    at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
    at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
    at...

的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.opentext.ix.ad</groupId>
    <artifactId>adservices</artifactId>
    <name>adservices</name>
    <packaging>war</packaging>
    <version>${build.number}</version>


    <properties>

        <!-- Generic properties -->
        <java.version>1.6</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Internal -->
        <ad-common.version>LATEST</ad-common.version>
        <addata.version>LATEST</addata.version>
        <primefaces-theme-tgo.version>01.00.00.01</primefaces-theme-tgo.version>
        <IMclient.version>07.24.00.03</IMclient.version>
        <wscommon.version>1.0</wscommon.version>
        <imqsclient.version>1.0</imqsclient.version>



        <!-- Spring -->
<!--        
        <spring-framework.version>3.1.2.RELEASE</spring-framework.version>

 -->        <spring-framework.version>3.2.9.RELEASE</spring-framework.version>

        <spring-data.version>1.4.1.RELEASE</spring-data.version>

        <!-- Other -->
        <servlet-api.version>3.0.1</servlet-api.version>
        <jackson.version>2.3.2</jackson.version>
        <flexjson.version>2.1</flexjson.version>
        <jsf.version>LATEST</jsf.version>
        <jsp-api.version>2.1</jsp-api.version>
        <jstl.version>1.2</jstl.version>
        <jboss-javaee.version>1.0.0.Final</jboss-javaee.version>
        <primefaces.version>4.0</primefaces.version>
        <primefaces.themes.version>LATEST</primefaces.themes.version>
        <commons-lang.version>2.6</commons-lang.version>
        <xstream.version>1.1.2</xstream.version>
        <el-impl.version>2.2</el-impl.version>
        <httpclient.version>4.3.3</httpclient.version>
        <json-path.version>0.8.1</json-path.version>
        <venus.version>8.0.0.5</venus.version>
        <reportservice.client.version>05.09.00.16</reportservice.client.version>
        <idocparser.version>1</idocparser.version>
        <reporthelper.version>1.0</reporthelper.version>
        <tg.common.version>5.6.0.0</tg.common.version>
        <wlthint3client.version>10.3.6.0</wlthint3client.version>

        <!-- Logging -->
        <slf4j-version>1.7.5</slf4j-version>
        <log4j.version>1.2.15</log4j.version>
        <tglogging.version>LATEST</tglogging.version>

        <!-- Test -->
        <junit.version>4.11</junit.version>
        <mockito.version>1.8.5</mockito.version>




        <ehcache.version>2.8.3</ehcache.version>

        <inject.version>1</inject.version>
        <jstl.version>1.2</jstl.version>

        <json-path.version>0.9.1</json-path.version>
        <json-path-assert.version>0.8.1</json-path-assert.version>

        <crc-system.version>2.0.11</crc-system.version>
        <cobertura.version>2.5.2</cobertura.version>


        <!-- Plugins -->
        <maven-eclipse-plugin.version>2.9</maven-eclipse-plugin.version>
        <maven-compiler-plugin.version>2.5.1</maven-compiler-plugin.version>
        <exec-maven-plugin.version>1.2.1</exec-maven-plugin.version>
        <maven-war-plugin.version>2.2</maven-war-plugin.version>

    </properties>


    <dependencies>

        <dependency>
            <groupId>com.mangofactory</groupId>
            <artifactId>swagger-springmvc</artifactId>
            <version>0.8.4</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring-web</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Temporary entry -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
            <scope>provided</scope>
        </dependency>

        <!-- Cache support -->
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>${ehcache.version}</version>
        </dependency>

        <!-- ADCommon project -->
        <dependency>
            <groupId>com.opentext.ix.ad</groupId>
            <artifactId>adcommon</artifactId>
            <version>${ad-common.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring-web</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-oxm</artifactId>
                    <groupId>org.springframework.ws</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- AD-DATA project -->
        <dependency>
            <groupId>com.opentext.ix.ad</groupId>
            <artifactId>addata</artifactId>
            <version>${addata.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.gxs</groupId>
                    <artifactId>tglogging</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-oxm</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-aop</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-jms</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring-framework.version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-aop</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring-framework.version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>

        </dependency>


        <dependency> 
             <groupId>org.springframework</groupId> 
             <artifactId>spring-aop</artifactId> 
            <version>${spring-framework.version}</version>
        </dependency>

        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-tx</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jdbc</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-oxm</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-orm</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring-framework.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-aop</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>

<!--        
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-oxm-tiger</artifactId>
            <version>1.5.4</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-oxm</artifactId>
                    <groupId>org.springframework.ws</groupId>
                </exclusion>
            </exclusions>
        </dependency>

 -->        
        <!-- jackson -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>



        <dependency>
            <groupId>net.sf.flexjson</groupId>
            <artifactId>flexjson</artifactId>
            <version>${flexjson.version}</version>
        </dependency>



        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j-version}</version>
        </dependency>

        <dependency>
            <groupId>com.gxs.tglogging</groupId>
            <artifactId>tglogging</artifactId>
            <version>${tglogging.version}</version>
        </dependency>

                <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>com.gxs.imclient</groupId>
            <artifactId>IMclient</artifactId>
            <version>${IMclient.version}</version>
        </dependency>

        <!-- GXS E2EUI Jars -->
        <dependency>
            <groupId>com.gxs.e2eui</groupId>
            <artifactId>wscommon</artifactId>
            <version>${wscommon.version}</version>
        </dependency>

        <dependency>
            <groupId>com.gxs.e2eui</groupId>
            <artifactId>imqsclient</artifactId>
            <version>${imqsclient.version}</version>
        </dependency>

        <dependency>
            <groupId>com.gxs.fms</groupId>
            <artifactId>FMSClient</artifactId>
            <version>LATEST</version>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>${inject.version}</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${servlet-api.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp-api.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring-framework.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <version>${json-path.version}</version>
            <scope>test</scope>

        </dependency>

        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path-assert</artifactId>
            <version>${json-path-assert.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.gxs</groupId>
            <artifactId>venus</artifactId>
            <version>${venus.version}</version>
        </dependency>


        <dependency>
            <groupId>com.gxs</groupId>
            <artifactId>reportservice-client</artifactId>
            <version>${reportservice.client.version}</version>
        </dependency>

        <dependency>
            <groupId>com.gxs.services.idoc</groupId>
            <artifactId>idocparser</artifactId>
            <version>${idocparser.version}</version>
        </dependency>

        <dependency>
            <groupId>com.gxs.services</groupId>
            <artifactId>reporthelper</artifactId>
            <version>${reporthelper.version}</version>
        </dependency>

        <dependency>
            <groupId>com.gxs.tgsdkcommon</groupId>
            <artifactId>tg-common</artifactId>
            <version>${tg.common.version}</version>
        </dependency>

        <dependency>
            <groupId>com.oracle.webLogicClient</groupId>
            <artifactId>wlthint3client</artifactId>
            <version>${wlthint3client.version}</version>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>


    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
        <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
        <resources>
            <resource>
                <directory>src/main/automation</directory>
                <filtering>true</filtering>
                <includes>
                    <include>component-Manifest.xml</include>
                </includes>
                <targetPath>..</targetPath>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://dtotcfa.qa.gxsonline.net:8080/manager/text</url>
                    <server>DevTomcatServer</server>
                    <path>/adservices</path>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>${maven-eclipse-plugin.version}</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin><!-- this tells maven not to add version to the artifact -->
                <artifactId>maven-war-plugin</artifactId>
                <version>${maven-war-plugin.version}</version>
                <configuration>
                    <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                    <outputFileNameMapping>@{artifactId}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
                    <archive>
                        <addMavenDescriptor>true</addMavenDescriptor>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Build-Time>${maven.build.timestamp}</Build-Time>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <!--  deploy to tomcat -->
            <!-- plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://ams935.edf.avctr.gxs.com:8887/manager/text</url>
                    <server>DevTomcatServer</server>
                    <path>/advs</path>
                </configuration>
            </plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec-maven-plugin.version}</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.github.jsimone</groupId>
                                    <artifactId>webapp-runner</artifactId>
                                    <version>7.0.40.0</version>
                                    <destFileName>webapp-runner.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/component-Manifest.xml</file>
                                    <type>xml</type>
                                    <classifier>automation</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <finalName>${project.artifactId}-${project.version}</finalName>
                </configuration>
                <executions>
                    <!-- For code, don't attach, to avoid redundant artifacts in Artifactory -->
                    <execution>
                        <id>assemble-noattach</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <attach>false</attach>
                            <descriptors>
                                <descriptor>src/main/assembly/code.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>assemble-attach</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/assembly/config.xml</descriptor>
                                <!-- Uncomment if needed <descriptor>src/main/assembly/scripts.xml</descriptor> 
                                    <descriptor>src/main/assembly/db.xml</descriptor> -->
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <configuration>
                    <tasks>
                        <copy file="${project.build.directory}/${project.artifactId}-${project.version}-code.tar.gz" tofile="${project.build.directory}/../build/dist/${project.artifactId}-${project.version}-code.tar.gz"/>
                        <copy file="${project.build.directory}/${project.artifactId}-${project.version}-config.tar.gz" tofile="${project.build.directory}/../build/dist/${project.artifactId}-${project.version}-config.tar.gz"/>
                        <copy file="${project.build.directory}/component-Manifest.xml" tofile="${project.build.directory}/../build/component-Manifest.xml"/>
                    </tasks>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>${cobertura.version}</version>
                <configuration>
                    <instrumentation>
                        <includes>
                            <include>com/opentext/ad/**/*.class</include>
                        </includes>
                        <ignores>
                        </ignores>                      
                        <excludes>
                        </excludes>
                    </instrumentation>
                </configuration>      
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>cobertura</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.17</version>
        <configuration>
            <systemPropertyVariables>
            <propertyName>propertyValue</propertyName>
                <com.gxs.common.logging.configfilepath>target/test-classes/LogCfg.xml</com.gxs.common.logging.configfilepath>
                <com.gxs.common.configuration.path>target/test-classes/crc</com.gxs.common.configuration.path>
                <com.gxs.common.configuration.proxy.envid>jvmid</com.gxs.common.configuration.proxy.envid>
                <com.gxs.common.configuration.localenvid>test</com.gxs.common.configuration.localenvid>
            </systemPropertyVariables>
        </configuration>
        </plugin>


        </plugins>
    </build>

</project>

1 个答案:

答案 0 :(得分:2)

  1. 右键单击Project&gt;属性&gt; Java构建路径&gt;订单和 导出标签。
  2. 确保M2_REPO / org / springframework / spring-beans / x.x.x.jar在上面 任何其他可能在旧版本中拖动的弹簧依赖项 弹簧豆。
  3. 在我的例子中,依赖于旧版spring-security的子项目高于Java构建路径顺序和导出列表中正确的spring-beans JAR。这意味着eclipse发现旧版本的spring-beans用于运行测试,旧版本没有所需的方法InjectionMetadata.needsRefresh。

    Maven足够聪明,只能编译各种JAR(如spring-beans)的最新版本,而Eclipse只是从构建路径中获取第一个,即使它比较旧并且不包含您需要的相关方法。