---
title: "tomcat7 集成 solr4.3.1"
author: "mywebcode"
date: "2013-11-10T12:14:00Z"
tags: []
slug: "tomcat7-solr4-3-1"
draft: false
lastmod: "2014-04-30T09:16:55Z"
id: 2058368
url: "https://mywebcode.iteye.com/blog/2058368"
---

本例使用的是：tomcat ：apache-tomcat-7.0.41

Solr : solr-4.3.1

步骤一：将下载下来的，solr-conf下的solr 文件拷贝到你机器的tomcat的webapps目录下

步骤二：Solr usesUTF-8 file encoding. That means that we need to ensure  
that Apache Tomcat will be informed that allrequests and responses made should use that  
encoding. To do that, we modified the server.xml file in the way shown in thefollowing code:

将你机器的tomcat的apache-tomcat-7.0.41\\conf下的server.xml中在

&lt;Connectorport="8080" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443"/&gt;后面添加URIEncoding="UTF-8"

如：

&lt;Connectorport="8080" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443"

URIEncoding="UTF-8"/&gt;

步骤三：将你下载的solr-conf目录下的tomcat need solr lib目录下的所有的lib全部拷贝到你机器的apache-tomcat-7.0.41\\lib 目录下。

![](http://img.blog.csdn.net/20131110121621937?watermark%2F2%2Ftext%2FaHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpY3Az%2Ffont%2F5a6L5L2T%2Ffontsize%2F400%2Ffill%2FI0JBQkFCMA=%3D%2Fdissolve%2F70%2Fgravity%2FSouthEast)

步骤四：将webapps\\solr\\WEB-INF\\web.xml打开，修改&lt;env-entry-value&gt;填写你tomcat指向solr路径&lt;/env-entry-value&gt;

&lt;env-entry&gt;

&lt;env-entry-name&gt;solr/home&lt;/env-entry-name&gt;

&lt;env-entry-value&gt;/put/your/solr/home/here&lt;/env-entry-value&gt;

&lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;

&lt;/env-entry&gt;

如：&lt;env-entry&gt;

&lt;env-entry-name&gt;solr/home&lt;/env-entry-name&gt;

&lt;env-entry-value&gt;E:/apache-tomcat-7.0.41/webapps/solr/solr&lt;/env-entry-value&gt;

&lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;

&lt;/env-entry&gt;

启动tomcat，可以看到日志信息，确认已经成功启动 打开http://localhost:8080/solr/

2.solr 配置文件说明

如果需要索引自己数据库的数据：

找到solr-conf\\solr\\solr\\collection1\\conf\\data-config 修改如下：

&lt;dataSourcetype="JdbcDataSource" name="ds-1"

driver="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost/wjscenter"

user="root"

password="uniteque"/&gt;

待续。。。。。。