2014-11-04 3 views
0

Мой Монго конфигурации выглядит следующим образомкак добавить конфигурацию опции Монго к весне

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

Все работает хорошо!

НоIn the 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> 

ответ

0

Свойство называется threadsAllowedToBlockForConnectionMultiplier в com.mongodb.MongoOptions

<bean id="options" class="com.mongodb.MongoOptions"> 
    <property name="connectionsPerHost" value="100"/> 
    <property name="threadsAllowedToBlockForConnectionMultiplier" value="5"/> 
    <property name="maxWaitTime" value="500"/> 
</bean> 
Смежные вопросы