我正在尝试使用基于xml配置的spring-data-solr。我的配置文件是:
$b=0
当我想将属性注入maxConnections并在solr-server属性中超时时,我收到以下错误:
<?xml version="1.0" encoding="UTF-8"?>
<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:solr="http://www.springframework.org/schema/data/solr"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/data/solr http://www.springframework.org/schema/data/solr/spring-solr.xsd">
<!-- Configures HTTP Solr server -->
<solr:solr-server id="solrServer" url="${solr.url}${solr.collection.name}"
timeout="${solr.time.out}" maxConnections="${solr.max.connections}"/>
<!-- Configures Solr template -->
<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
<constructor-arg index="0" ref="solrServer"/>
</bean>
</beans>
有没有办法将属性字段注入那些int定义的属性? 谢谢你:D
答案 0 :(得分:0)
找到另一种解决方法后,最后不是在我的xml配置中定义solr-server,而是定义HttpSolrServerFactoryBean,如果我们在xml中定义它,则返回solr-server。
<?xml version="1.0" encoding="UTF-8"?>
<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:solr="http://www.springframework.org/schema/data/solr"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/solr http://www.springframework.org/schema/data/solr/spring-solr.xsd">
<!-- Configures HTTP Solr server -->
<!--<solr:solr-server id="solrServer" url="${solr.url}${solr.collection.name}"
timeout='${solr.timeout}' maxConnections='${solr.max.connections}'/>-->
<bean id="solrServer" class="org.springframework.data.solr.server.support.HttpSolrServerFactoryBean">
<property name="url" value="${solr.url}${solr.collection.name}"/>
<property name="timeout" value="${solr.timeout}"/>
<property name="maxConnections" value="${solr.max.connections}"/>
</bean>
<!-- Configures Solr template -->
<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
<constructor-arg index="0" ref="solrServer"/>
</bean>
</beans>
三江源。