简体   繁体   English

如何将apache solr与eclipse和Apache tomcat集成

[英]How to integrate apache solr with eclipse and Apache tomcat

It is very difficult to get started with apache solr in eclipse.I am new to apache solr was trying to integrate it with eclipse so that I can develop web application for same.I have searched lot of link but nothing useful.I have downloaded apache solr 5.0 but not able to get integrate with eclipse in windows 在eclipse中开始使用apache solr是非常困难的。我是apache solr的新手,我试图将其与eclipse集成以便我可以为其开发Web应用程序。我搜索了很多链接但没有用。我已经下载了apache solr 5.0,但无法与Windows中的eclipse集成

Please provide any step wise step solution and also provide some good examples. 请提供任何逐步的解决方案,并提供一些良好的示例。

Since you said "I am new to Solr" I think you don't need to load it in Eclipse. 因为您说过“我对Solr还是陌生的”,所以我认为您不需要在Eclipse中加载它。 Solr is a kind of service so unless you want to develop some customisation (eg plugin, search component, parser) which is an advanced topic, it can be started externally from command line. Solr是一种服务,因此除非您想开发一些高级主题(例如插件,搜索组件,解析器),否则可以从命令行从外部启动它。

Then, in Eclipse, you may want to 然后,在Eclipse中,您可能想要

  • link in your project the folder that contains the configuration files, so you can edit them in Eclipse 在您的项目中链接包含配置文件的文件夹,以便您可以在Eclipse中对其进行编辑
  • import the solrj libraries if you need to index data in some way that is not covered by the defaut set of tools that solr offers (eg SolrCell, DataImportHandler) 如果您需要以某种solr提供的默认工具集无法涵盖的方式对数据建立索引,则导入solrj库(例如SolrCell,DataImportHandler)

But again, at least for a primer usage, I don't see the need to import and manage it from Eclipse. 但是同样,至少对于入门而言,我认为不需要从Eclipse导入和管理它。 A compromise could be an external launch configuration (in Eclipse) that hides the command line (for starting and stopping Solr) 一个妥协可能是隐藏命令行(用于启动和停止Solr)的外部启动配置(在Eclipse中)。

It is very easy if you know all steps.Here I am providing all steps one by one 如果您知道所有步骤,这非常容易。在这里,我一步一步地提供所有步骤

  1. Install Apache Tomcat 7 or any other and change its port to 84 or your desired port no when installing apache tomcat 安装Apache Tomcat 7或其他任何端口,并在安装apache tomcat时将其端口更改为84或所需的端口号
  2. Download Solr 4.6 zip and extract it 下载Solr 4.6 zip并将其解压缩
  3. Copy solr folder from example folder of solr 4.6 and create a folder name solr in C drive and paste content in this folder 从solr 4.6的示例文件夹中复制solr文件夹,并在C驱动器中创建一个文件夹名称solr并将内容粘贴到此文件夹中
  4. Copy solr-4.6 war from dist folder to Tomcat webapps folder and rename it to solr.war automatically solr folder will be created 将solr-4.6 war从dist文件夹复制到Tomcat webapps文件夹并将其重命名为solr.war将自动创建solr文件夹
  5. Copy all war files from dist-->solrj-->lib to tomcat-->lib folder 将所有war文件从dist-> solrj-> lib复制到tomcat-> lib文件夹
  6. Inside tomcat-->conf-->Catalina-->localhost create xml file solr.xml 在tomcat内-> conf-> Catalina-> localhost创建xml文件solr.xml

solr.xml solr.xml

<?xml version='1.0' encoding='UTF-8'?>
<context docBase="C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/solr.war" debug="0" crossContext="true" >
    <environment name="solr" type="java.lang.String" value="/Tomcat 7.0/webapps/" override="true"></environment>
</context>

7. Inside tomcat-->webapp-->solr-->WEB-INF-->web.xml set Environment entry it will look like this 7.在tomcat-> webapp-> solr-> WEB-INF-> web.xml设置环境条目中,它看起来像这样

  <env-entry>
   <env-entry-name>solr</env-entry-name>
   <env-entry-value>C:\solr</env-entry-value>
   <env-entry-type>java.lang.String</env-entry-type>
</env-entry>

Now you are all set with apache solr use enjoy 现在,您已全部使用apache solr进行使用

http://localhost:84/solr/#/ HTTP://本地主机:84 / solr的/#/

Since you have asked about Solr5.0, Beginning with Solr 5.0, Support for deploying Solr as a WAR in servlet containers like Tomcat is no longer supported. 既然您已经询问过Solr5.0,从Solr 5.0开始,就不再支持将Solr作为WAR部署在Tomcat之类的servlet容器中的支持。 For information on how to install Solr as a standalone server, please see Installing Solr- https://cwiki.apache.org/confluence/display/solr/Installing+Solr 有关如何将Solr安装为独立服务器的信息,请参阅安装Solr- https://cwiki.apache.org/confluence/display/solr/Installing+Solr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM