Bean property' trustStore'不可写或具有无效的setter方法。 setter的参数类型是否与getter的返回类型匹配?

时间:2016-12-05 09:11:09

标签: java spring spring-security keystore truststore

我收到以下错误:

...
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]

我需要在我的应用程序上下文中加载信任库,ad我尝试的方式与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>

关于我做错了什么的任何建议?

1 个答案:

答案 0 :(得分:3)

问题不在于Spring KeyStoreFactoryBean,问题是你的 HttpClientBuilderFactory类没有trustStore属性或缺少一个setter。仔细检查课程。