日期:2014-05-20  浏览次数:20821 次

采用compass实现搜索功能
我采用的是spring2.5+JPA+compass集成
compass在spring的中的配置如下:
<bean id="compass" class="org.compass.spring.LocalCompassBean">
<property name="classMappings">
<list>
<value>com.core.beans.product.ProductInfo</value>
<value>com.core.beans.product.Brand</value>
<value>com.core.beans.product.ProductStyle</value>
<value>com.core.beans.product.ProductType</value>
</list>
</property>
<property name="compassSettings">
<props>
<prop key="compass.engine.analyzer.default.type">net.paoding.analysis.analyzer.PaodingAnalyzer</prop>
<prop key="compass.engine.connection">file://e:/index</prop>
<!-- 在内存中建立索引
<prop key="compass.engine.connection">ram://index</prop>
-->
<prop key="compass.engine.highlighter.default.formatter.simple.pre"><![CDATA[<font color='red'>]]></prop>
<prop key="compass.engine.highlighter.default.formatter.simple.post"><![CDATA[</font>]]></prop>
<prop key="compass.transaction.factory">org.compass.spring.transaction.SpringSyncTransactionFactory</prop>
</props>
</property>
<property name="transactionManager" ref="transactionManager" />
</bean>

<!-- 自动完成 索引的添加/更新/删除操作-->
<bean id="compassGps" class="org.compass.gps.impl.SingleCompassGps" init-method="start" destroy-method="stop">
<property name="compass" ref="compass" />
<property name="gpsDevices">
<list>
<!-- 设置JPA驱动 -->
<bean class="org.compass.gps.device.jpa.JpaGpsDevice">
<property name="name" value="jpaDevice" />
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="injectEntityLifecycleListener" value="true"/>
</bean>
</list>
</property>
</bean>




这下面是错误信息:




org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'compass' defined in file [D:\apache-tomcat-6.0.18\webapps\ROOT\WEB-INF\classes\applicationContext-common.xml]: Invocation of init method failed; nested exception is org.compass.core.engine.SearchEngineException: Setting type of FS directory is a JVM level setting, you can not set different values within the same JVM
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)