我的項目需要SSL認證機制EXTERNAL(僅使用SSL證書並避免rabbitmq上的用戶名/密碼)。對於connectionfactory bean,我們給了屬性name =「saslConfig」value =「DefaultSaslConfig.EXTERNAL」,但是我們得到一個錯誤:「無法將[java.lang.String]類型的值轉換爲所需的類型[com.rabbitmq.client .SaslConfig]屬性'saslConfig':找不到匹配的編輯或轉換策略「。我們嘗試了其他值,例如value =「com.rabbitmq.client.DefaultSaslConfig.EXTERNAL」和value =「EXTERNAL」,但仍然存在錯誤。你可以請檢查下面的配置和日誌,並提供給我你的建議。使用spring rabbitmq不起作用的saslConfig
bean配置
<rabbit:connection-factory id="connectionFactory" connection-factory="clientConnectionFactory" host="x.y.z.m" port="5671"/>
<bean id="clientConnectionFactory" class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean">
<property name="useSSL" value="true" />
<property name="saslConfig" value=com.rabbitmq.client.DefaultSaslConfig.EXTERNAL"/>
<property name="sslPropertiesLocation" value="classpath:/rabbitSSL.properties"/></bean>
日誌
Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.rabbitmq.client.SaslConfig] for property 'saslConfig': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:306)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:576)