所需软件:solr4.8.1、Tomcat7
下载完相应软件后开始单机部署(windows下)
- 在F盘根目录创建solr文件夹,并解压solr4.8和tomcat7到该文件夹
- 在F盘根目录创建solrhome文件夹,将F:\solr\solr-4.8.1\example\solr下的所有文件复制到solrhome文件夹中
- 将F:\solr\solr-4.8.1\dist下的solr-4.8.1.war复制到tomcat7的webapps下并更名为solr.war
- 在F:\solr\apache-tomcat-7.0.53\conf\Catalina\localhost下新建solr.xml,文件内容如下:
-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Context docBase="F:\solr\apache-tomcat-7.0.53\webapps\solr.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="F:\solr\solrhome" override="true" /> </Context>
- 然后启动tomcat,然而并不能启动成功,抛出了异常查看日志文件:
严重: Exception starting filter SolrRequestFilter java.lang.NoClassDefFoundError: Failed to initialize Apache Solr: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging at org.apache.solr.servlet.CheckLoggingConfiguration.check(CheckLoggingConfiguration.java:28) at org.apache.solr.servlet.BaseSolrFilter.<clinit>(BaseSolrFilter.java:31) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:374)
- 很明显:: Could not find necessary SLF4j logging jars 缺少SLF4J.jar
- 最后将F:\solr\solr-4.8.1\example\lib\ext下的lib复制到F:\solr\apache-tomcat-7.0.53\webapps\solr\WEB-INF\lib下重启tomcat即可
- 访问http://localhost:8080/solr