Моя конфигурация монго выглядит так
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd">
<bean id="mongo" class="com.mongodb.Mongo">
<constructor-arg name="addr" ref="address" />
<constructor-arg name="options" ref="options" />
</bean>
<bean id="options" class="com.mongodb.MongoOptions">
<property name="connectionsPerHost" value="100"/>
<property name="maxWaitTime" value="500"/>
</bean>
<bean id="address" class="com.mongodb.ServerAddress">
<constructor-arg name="host" value="X.X.X.X" />
<constructor-arg name="port" value="27017" />
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongo" />
<constructor-arg name="databaseName" value="test" />
</bean>
...
Все работает хорошо!
Но в Mongo XSD, есть письменный атрибут с именем «потоки, разрешенные для блокировки для множителя соединения». Когда я добавляю это, у меня есть такая ошибка:
org.springframework.beans.NotWritablePropertyException: Invalid property 'threads-allowed-to-block-for-connection-multiplier' of bean class [com.mongodb.MongoOptions]: Bean property 'threads-allowed-to-block-for-connection-multiplier' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Вы знаете, что происходит? Мой новый xml выглядит так:
<bean id="options" class="com.mongodb.MongoOptions">
<property name="connectionsPerHost" value="100"/>
<property name="threads-allowed-to-block-for-connection-multiplier" value="5"/>
<property name="maxWaitTime" value="500"/>
</bean>