Build and run the SOLR project on Eclipse

Source: Internet
Author: User

First, create a Dynamic Web project

Because Maven is troublesome, it runs on eclipse in the form of a Web project

II. the structure of the war package directory with SOLR's own

Third, copy the above content to the Web project WebContent

Iv. modifying Web. xml

Add a listener to load the SOLR index address

<listener>      <listener-class>          com.iflashbuy.solr.Solrlistener      </listener-class>  </listener>



Package Com.iflashbuy.solr;import Javax.servlet.servletcontextevent;import javax.servlet.servletcontextlistener;/ * * Solr.solr.home is set through the listener and needs to be configured on the Web. XML * @author Limanman * */public class Solrlistener implements Servletcontextlistene R {/* * (NON-JAVADOC) * * @see javax.servlet.servletcontextlistener#contextdestroyed (javax.servlet. * servletcontextevent) */public void contextdestroyed (Servletcontextevent sce) {//TODO auto-generated Method stub}/* * (No N-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";p ath = "D:/limanman/workspace/eclipse-luna/sgint_solr_server/webcontent/home/collection1";//jetty will error So I directly wrote this path System.setproperty ("Solr.solr.home", Path);}}



V. Add the relevant index directory to the cable location specified in the above steps

Vi. run the project and visitHTTP://LOCALHOST:8993/SOLR


Of course you can also run your personal habits through eclipse in Tomcat.


Vii. Initializing Index Directory

The default data folder and Core.properties in the above image are not, by accessing HTTP://LOCALHOST:8993/SOLR, adding the corresponding index in the console, the index name and the corresponding folder name are the same interface.

Build and run the SOLR project on Eclipse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.