applicationcontext.xml 中未反映自定义配置

Custom configuration not getting reflected in applicationcontext.xml

我正在为我的 RabbitMQ 连接使用自定义配置。我正在连接到多个主机。

<context:property-placeholder location="classpath:/test_setting.properties" ignore-unresolvable="true"/>
...
<rabbit:connection-factory id="testConnectionFactory"
    addresses="${test.addresses}" 
    username="${test.username}"
    password="${test.password}" 
    virtual-host="${test.virtualhost}"
    connection-factory="rhb" />

<bean id="rhb" class="com.rabbitmq.client.ConnectionFactory">
     <property name="requestedHeartbeat" value="${test.connection.heartbeat}" />
</bean>

我的 属性 文件如下所示:test_setting.properties

test.queue=testQueue
test.virtualhost=/global_api
test.addresses=host1:5672,
               host2:5672
test.username=guest
test.password=guest
test.connection.heartbeat=60
test.consumer.concurrency=1

当我触发我的主要 class 属性时,在 Spring 中的 applicationcontext.xml 中没有被替换。因此我得到连接被拒绝的异常。
请注意,如果我对连接详细信息进行硬编码,则一切正常。

ignore-unresolvable="true"

似乎找不到文件 - 将其更改为 false 以查看错误。

此外,为 org.springframework 打开 DEBUG 日志记录将提供大量有关 属性 解决方案的信息。

test.addresses=host1:5672,
               host2:5672

属性必须在一行上(您可以用 \ 终止一行)才能继续。

test.addresses=host1:5672, \
               host2:5672