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