Bean 属性 'trustStore' 不可写或具有无效的 setter 方法。 setter 的参数类型是否匹配 getter 的 return 类型?

Bean property 'trustStore' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

我收到以下错误:

...
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'trustStore' of bean class [it.gvb.arch.connector.http.HttpClientBuilderFactory]: Bean property 'trustStore' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1076) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:927) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1510) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

我需要在我的应用程序上下文中加载一个信任库,我正在尝试与 Spring Documentation 中解释的相同方式,所以我这样配置我的 bean:

<bean id="secTrustStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean">
    <property name="password" value="${http.truststore.password:#{null}}"/>
    <property name="location" value="${http.truststore.location:#{null}}"/>
    <property name="type" value="${http.truststore.type:pkcs12}"/>
</bean>

对我做错了什么有什么建议吗?

问题不是Spring的KeyStoreFactoryBean,问题是你的HttpClientBuilderFactoryclass没有trustStore 属性 或缺少 setter。仔细检查 class.