Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用spring概要文件和gradle运行集成测试_Java_Spring_Gradle - Fatal编程技术网

Java 使用spring概要文件和gradle运行集成测试

Java 使用spring概要文件和gradle运行集成测试,java,spring,gradle,Java,Spring,Gradle,我有以下上下文文件 <?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"

我有以下上下文文件

   <?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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:encryption="http://www.jasypt.org/schema/encryption"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd 
        http://www.jasypt.org/schema/encryption http://www.jasypt.org/schema/encryption/jasypt-spring31-encryption-1.xsd">

    <import resource="dao-context.xml"/>
    <import resource="web-context.xml"/>
    <import resource="messaging-context.xml"/>

    <context:component-scan base-package="uk.co.testcompany.com"/>

    <bean id="bcProvider" class="org.bouncycastle.jce.provider.BouncyCastleProvider" />
    <bean id="saltProvider" class="org.jasypt.salt.RandomSaltGenerator"/>

    <encryption:string-digester 
        algorithm="SHA-256"
        iterations="10000"
        salt-size-bytes="20"
        provider-bean="bcProvider"
        salt-generator-bean="saltProvider"/>


    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="properties/rest_messages"/>
    </bean>

    <task:executor id="simpleExecutor" pool-size="5"  />
    <task:annotation-driven executor="simpleExecutor"/>

    <aop:aspectj-autoproxy />

    <bean id="loggingAspect" class="uk.co.testcompany.com.aspect.RequestLoggingAspect"></bean>

    <beans profile="dev">
        <context:property-placeholder location="classpath:/properties/dev/*.properties"/>
    </beans>

    <beans profile="test">
        <context:property-placeholder location="classpath:/properties/test/*.properties"/>
    </beans>

</beans>
我的构建过程使用gradle。现在本地一切正常,我在命令行上运行cleanbuild,没有问题。但是,每当我尝试在持续集成服务器上运行此操作时,都会出现以下错误:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:上下文中只能存在一个AsyncAnnotationBeanPostProcessor

我有点不明白为什么会这样,因为它在本地工作。如果it在CI服务器上失败但在本地通过,可能会出现什么问题


干杯

您在子测试中有@ContextConfiguration注释吗?这个错误明确地表明spring上下文被初始化了好几次有趣的是,当我删除了dev和test的两个“”定义,并且有一个bog标准属性占位符配置定义时,它就工作了。出于某些原因,我无法使用概要文件。在子测试中是否有@ContextConfiguration注释?该错误明确表示spring上下文已初始化多次有趣的是,当我删除了dev和test的两个“”定义,并具有bog标准属性占位符配置定义时,它可以工作。由于某些原因,我不能使用配置文件。
import org.junit.runner.RunWith;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { 
                                    "classpath*:/spring/root-context.xml",
                                    "classpath*:/spring/test-utils-context.xml"
                                  })
@Transactional
@ActiveProfiles("dev")
public abstract class IntegrationTestBase {


}