Spring @配置文件不';无法使用消息传递网关

Spring @配置文件不';无法使用消息传递网关,spring,spring-boot,spring-integration,profile,Spring,Spring Boot,Spring Integration,Profile,在我的集成应用程序中,我定义了一个简单的网关,如下所示: @MessagingGateway @Profile(value = { "export" }) public interface ExportingOutboundGateway { @Gateway(requestChannel = "exportChannel") void send(RequestInfo request); } 如果我使用application.properties中声明的Spring.p

在我的集成应用程序中,我定义了一个简单的网关,如下所示:

@MessagingGateway
@Profile(value = { "export" })
public interface ExportingOutboundGateway {

     @Gateway(requestChannel = "exportChannel")
     void send(RequestInfo request);
}
如果我使用application.properties中声明的Spring.profiles.active=export执行此Spring引导应用程序,则无法创建网关bean


网关bean的定义有错误吗?如何修复它?

这是
IntegrationComponentScanRegistrar
中的一个错误。当我们扫描
@MessagingGateway
接口时,我们不尊重应用程序上下文中的
环境
,而内部
ClassPathScanningCandidateComponentProvider
只是使用一个默认的接口,我们没有该活动配置文件

作为一种解决方法,我建议如下:

@Bean
@Profile("export")
public AnnotationGatewayProxyFactoryBean exportingOutboundGateway() {
    return new AnnotationGatewayProxyFactoryBean(ExportingOutboundGateway.class);
}

...

public interface ExportingOutboundGateway {

    @Gateway(requestChannel = "exportChannel")
    void send(String request);

}

关于这个问题的一点建议:

谢谢Artem Bilan,顺便说一句,它仍然与系统属性源一起工作,不是吗?如果你是指配置文件,那么是的,激活配置文件的源是什么并不重要。是的,我指的是配置文件。谢谢我要试试解决办法