0

I'm trying using spring-data-solr using xml based configuration. My configuration file is :

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

When i want to inject property to maxConnections and timeout in solr-server attribute i got the following error :

cvc-datatype-valid.1.2.1: '${solr.time.out}' is not a valid value for 'integer'.

Is there any way to inject property field to those int defined attribute? Thankyou :D

screen-shoot

  • Do you have these properties defined in any properties file, say `solr.properties`? If so, you can add context namespace to spring xml file and add `` and try. – Madhusudana Reddy Sunnapu Jan 24 '16 at 14:48
  • Hi Madhusudana Reddy Sunnapu, i already done that in my another spring-context configuration file. When i hardcoded the timeout and maxConnections the config works fine. But when i change it into the property variable its not working. I wonder is there any way to ignore the xsd attribute type validation? – hermawan.sugoi Jan 24 '16 at 15:09

1 Answers1

0

after finding another workaround, finally instead of defining solr-server in my xml config, i define HttpSolrServerFactoryBean which return solr-server if we define it in xml.

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

Thankyou.