You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot应用中spring.integration.properties配置未被识别求助

问题解决:Spring Integration默认超时配置不生效

可能原因

在Spring Boot环境中,META-INF/spring.integration.properties的配置优先级低于Spring Boot的外部配置源(如application.properties、系统属性、环境变量等),即便你能读取到该文件,其配置也可能被默认的30000值覆盖。

解决方案

方案1:改用Spring Boot标准配置文件(推荐)

直接在application.properties或application.yml中添加配置:

spring.integration.endpoints.defaultTimeout=-1

或YAML格式:

spring:
  integration:
    endpoints:
      defaultTimeout: -1

Spring Boot会自动将该属性绑定到IntegrationProperties,优先级高于META-INF/spring.integration.properties,确保配置生效。

方案2:手动加载spring.integration.properties到Spring Environment

如果必须使用META-INF/spring.integration.properties,可以通过自定义配置类手动将其加载为高优先级的PropertySource:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.core.env.MapPropertySource;

import java.io.IOException;
import java.util.Properties;

@Configuration
public class IntegrationPropertyConfig {

    @Bean
    public MapPropertySource customIntegrationProperties() throws IOException {
        Properties integrationProps = PropertiesLoaderUtils.loadProperties(
                new ClassPathResource("META-INF/spring.integration.properties"));
        // 设置较高优先级的名称,确保覆盖默认配置
        return new MapPropertySource("customIntegrationProperties", integrationProps);
    }
}

方案3:检查是否存在属性覆盖

排查是否有其他配置源设置了spring.integration.endpoints.defaultTimeout:

  • 启动时的系统参数(如-Dspring.integration.endpoints.defaultTimeout=30000)
  • 系统环境变量
  • application.properties/application.yml中的冲突配置
  • 其他自定义PropertySource

这些配置源的优先级均高于META-INF/spring.integration.properties,需确保没有重复设置该属性。


内容的提问来源于stack exchange,提问作者Chris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 22:39:57