有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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"
    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>

我想在运行集成测试时使用dev概要文件。我有一个抽象的集成测试基类,所有东西都是从这个基类扩展而来的。看起来是这样的:

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 {


}

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

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Only one AsyncAnnotationBeanPostProcessor may exist within the context.

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

干杯


共 (0) 个答案