solr 安装
1、可以去http://apache.freelamp.com/lucene/solr/1.4.0/apache-solr-1.4.0.zip下载solr
2、解压apache-solr-1.4.0到D:\apache-solr-1.4.0
3、找到D:\apache-solr-1.4.0\example\webapps下的solr.war,放到D:\DOWNLOADS\apache-tomcat-5.5.30\webapps
4、启动tomcat,肯定会出错。
5、修改web.xml,增加一个监听
?<listener>
??<listener-class>
???com.szhtp.solr.Solrlistener
??</listener-class>
?</listener>
?
6、
public class Solrlistener implements ServletContextListener{ /* (non-Javadoc) * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) */ public void contextDestroyed(ServletContextEvent sce) { // TODO Auto-generated method stub } /* (non-Javadoc) * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent sce) { String path = this.getClass().getResource("/").getPath(); int lastNum = path.lastIndexOf("WEB-INF/classes/"); path = path.substring(0, lastNum) + "/solr"; System.setProperty("solr.solr.home", path); }}
?7、把D:\apache-solr-1.4.0\example下的solr文件夹拷贝到D:\DOWNLOADS\apache-tomcat-5.5.30\webapps\solr下
8、把com.szhtp.solr.Solrlistener.java打成jar放到D:\DOWNLOADS\apache-tomcat-5.5.30\webapps\solr\WEB-INF\lib下就可以了
9、启动tomcat没有错误OK