如何在eclipse中部署solr的web工程

2024-11-21 13:26:03
推荐回答(1个)
回答1:

首先在eclipse(散仙这里是4.2)里,新建一个动态的Web工程,
然后起一个项目名叫solrweb,如果第一次使用需要配置一下web容器,tomcat或jetty
点击new runtime配置tomcat容器,前提是你下载好的tomcat解压保存在某个盘符下,
然后配置tomcat的路径
然后finish,建完后的项目结果如下所示:
接下来,删除WebContent下的所有内容,到解压后的solr的solr-4.10.0\example\webapps目录下,解压solr.war包,然后拷贝解压后所有的东西(除了solr.war本身),到刚才被清空的WebContent目录下:
拷贝完后的项目工程如下所以,注意这里可能由于js校验出错,不影响运行,可忽略,如果有洁癖的同学们,可以找下,如何去掉js的校验即可。
然后在E盘目录下,新建一个文件夹命名为solr_home,然后拷贝solr-4.10.0\example\solr下的所有文件到这个solr_home的文件夹下,拷贝后的目录如下:
接下来配置在eclipse的solrweb项目里的WebContent\WEB-INF下的web.xml文件去掉注释solr_home的标签,把刚才在E盘配置的路径放进去:
然后拷贝solr\solr-4.10.0\example\lib\ext下所有的日志包到我们项目的lib目录下:
并拷贝solr-4.10.0\example\resources\下的log4j.properties文件到我们工程的src目录下
,然后右击项目启动,run server,我们的控制台就会打印如下信息:

十二月 11, 2014 9:04:08 下午 org.apache.catalina.core.AprLifecycleListener init 
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Java\jdk1.7.0_04\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:/Java/jdk1.7.0_04/bin/../jre/bin/server;D:/Java/jdk1.7.0_04/bin/../jre/bin;D:/Java/jdk1.7.0_04/bin/../jre/lib/amd64;D:\git\Git\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;D:\Java\jdk1.7.0_04\bin;D:\Java\jdk1.7.0_04\jre\bin;D:\apache-ant-1.9.3\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Lenovo\Lenovo Home\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\TortoiseSVN\bin;D:\hadoop-2.2.0/bin;C:\MyProgramFiles\apache-maven-3.0.5\bin;D:\python;D:\eclipsehadoop2.2.0\eclipse;;.
十二月 11, 2014 9:04:08 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:solrweb' did not find a matching property.
十二月 11, 2014 9:04:08 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
十二月 11, 2014 9:04:08 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
十二月 11, 2014 9:04:08 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 434 ms
十二月 11, 2014 9:04:08 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十二月 11, 2014 9:04:08 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.47
0 [localhost-startStop-1] INFO org.apache.solr.servlet.SolrDispatchFilter – SolrDispatchFilter.init()
13 [localhost-startStop-1] INFO org.apache.solr.core.SolrResourceLoader – Using JNDI solr.home: E://solr_home//
15 [localhost-startStop-1] INFO org.apache.solr.core.SolrResourceLoader – new SolrResourceLoader for directory: 'E://solr_home//'
159 [localhost-startStop-1] INFO org.apache.solr.core.ConfigSolr – Loading container configuration from E:\solr_home\solr.xml
223 [localhost-startStop-1] INFO org.apache.solr.core.CoresLocator – Config-defined core root directory: E:\solr_home
229 [localhost-startStop-1] INFO org.apache.solr.core.CoreContainer – New CoreContainer 357471660
229 [localhost-startStop-1] INFO org.apache.solr.core.CoreContainer – Loading cores into CoreContainer [instanceDir=E://solr_home//]
243 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting socketTimeout to: 0
243 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting urlScheme to: null
246 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting connTimeout to: 0
246 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting maxConnectionsPerHost to: 20
246 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting corePoolSize to: 0
246 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting maximumPoolSize to: 2147483647
246 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting maxThreadIdleTime to: 5
246 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting sizeOfQueue to: -1
247 [localhost-startStop-1] INFO org.apache.solr.handler.component.HttpShardHandlerFactory – Setting fairnessPolicy to: false
334 [localhost-startStop-1] INFO org.apache.solr.update.UpdateShardHandler – Creating UpdateShardHandler HTTP client with params: socketTimeout=0&connTimeout=0&retry=false
336 [localhost-startStop-1] INFO org.apache.solr.logging.LogWatcher – SLF4J impl is org.slf4j.impl.Log4jLoggerFactory
337 [localhost-startStop-1] INFO org.apache.solr.logging.LogWatcher – Registering Log Listener [Log4j (org.slf4j.impl.Log4jLoggerFactory)]
338 [localhost-startStop-1] INFO org.apache.solr.core.CoreContainer – Host Name:
370 [localhost-startStop-1] INFO org.apache.solr.core.CoresLocator – Looking for core definitions underneath