1. 将 apache-solr-dataimportscheduler-1.1.jar 和solr自带的 apache-solr-dataimporthandler-5.1.0.jar, apache-solr-dataimporthandler-extras-5.1.0.jar 放到 tomcat/webapps/solr/WEB-INF/lib/ 目录下面
2.修改tomcat/webapps/solr/WEB-INF/中的web.xml, 在servlet节点前面增加:
3.将apache-solr-dataimportscheduler-1.1.jar 中 dataimport.properties 取出并根据实际情况修改,然后放到 solr_home/conf (不是solr_home/core1/conf) 目录下面,solr_home/conf文件夹没有的话手动创建
4.重启tomcat
dataimport.properties 配置项修改说明:
- #################################################
- # #
- # dataimport scheduler properties #
- # #
- #################################################
- # to sync or not to sync
- # 1 - active; anything else - inactive
- syncEnabled=1
- # which cores to schedule
- # in a multi-core environment you can decide which cores you want syncronized
- # leave empty or comment it out if using single-core deployment
- syncCores=core1
- # solr server name or IP address
- # [defaults to localhost if empty]
- server=localhost
- # solr server port
- # [defaults to 80 if empty]
- port=8080
- # application name/context
- # [defaults to current ServletContextListener's context (app) name]
- webapp=solr
- # URL params [mandatory]
- # remainder of URL
- #增量
- params=/dataimport?command=delta-import&clean=false&commit=true&optimize=false&wt=json&indent=true&entity=students&verbose=false&debug=false
- # schedule interval
- # number of minutes between two runs
- # [defaults to 30 if empty]
- interval=20
- # 重做索引的时间间隔,单位分钟,默认7200,即1天;
- # 为空,为0,或者注释掉:表示永不重做索引
- reBuildIndexInterval=7200
- # 重做索引的参数
- reBuildIndexParams=/dataimport?command=full-import&clean=true&commit=true&optimize=true&wt=json&indent=true&entity=students&verbose=false&debug=false
- # 重做索引时间间隔的计时开始时间,第一次真正执行的时间=reBuildIndexBeginTime+reBuildIndexInterval*60*1000;
- # 两种格式:2012-04-11 03:10:00 或者 03:10:00,后一种会自动补全日期部分为服务启动时的日期
- reBuildIndexBeginTime=09:00:00
为什么会爆这个错,因为SolrDataImportProperties类的loadProperties方法里面:
SolrResourceLoader是solr里面的核心方法,这里传了一个null,但是后面有调用了一个方法,但是我看源码发现没有这个方法,应该是新的版本改了;
上面我做了一点改动,调用无参的构造方法,重新编译打包jar,之后就可以完美运行了;
jar:https://pan.baidu.com/s/1o8jxn8u
源码:https://pan.baidu.com/s/1kUGxnld