由于通过配置的方式定时更新不生效,故通过代码执行定时任务更新

package com.thinkgem.jeesite.modules.meeting.task;

import java.io.IOException;

import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; /**
* @ClassName: SolrTask
* @Description:
* @author wd
* @date 2018年3月23日 上午11:13:22
*
*/
@Service
@Lazy(false)
public class SolrTask { @Value("#{APP_PROP['solr.Core.full']}")
private String coreUrlfull; @Value("#{APP_PROP['solr.Core.delta']}")
private String coreUrldelta; private static final Logger LOGGER = LoggerFactory.getLogger(SolrTask.class); /**
*
* 适用于修改 新增 (删除未做)
* 每日零点
* @throws IOException
*/
@Scheduled(cron = "0 0 0 * * ?")
public void SolrTaskDelta() throws IOException {
CloseableHttpClient httpCilent = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(coreUrldelta);
try {
CloseableHttpResponse response = httpCilent.execute(httpGet);
if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
LOGGER.info("solr增量索引任务执行成功" );
}
} catch (IOException e) {
LOGGER.info("solr增量索引任务执行失败");
e.printStackTrace();
}finally {
httpCilent.close();
}
} /**
* 每周一零点
* 全量索引删除后重建
* @throws IOException
*
*/
@Scheduled(cron = "0 0 0 ? * MON ")
public void SolrTaskFull() throws IOException {
CloseableHttpClient httpCilent = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(coreUrlfull);
try {
CloseableHttpResponse response = httpCilent.execute(httpGet);
if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
LOGGER.info("solr重建全量索引成功" );
}
} catch (IOException e) {
LOGGER.info("solr重建全量索引失败");
e.printStackTrace();
}finally {
httpCilent.close();
}
}
}
#期刊索引更新测试服务器
solr.Core.delta=http://10.1.101.134:8983/solr/PaperReview/dataimport?command=delta-import&clean=false&commit=true
solr.Core.full=http://10.1.101.134:8983/solr/PaperReview/dataimport?command=full-import&clean=true&commit=true

最新文章

  1. iOS代码规范(OC和Swift)
  2. Java中private、protected、public和default的区别
  3. CSS样式基础总结
  4. Java第八周学习总结
  5. 获取 Chromium 源代码以及环境配置
  6. 显式激活数据库( ACTIVATE DATABASE)
  7. the differences between function and procedure
  8. 苹果新的编程语言 Swift 语言进阶(六)--函数和闭包
  9. 利用UICollectionView实现瀑布流
  10. 彻底明白Java的IO系统
  11. git 恢复本地误删文件
  12. c++中的左值与右值
  13. 我对CopyOnWrite的思考
  14. 62.纯 CSS 创作一只蒸锅(感觉不好看呀)
  15. Jenkins之Linux和window配置区别
  16. Maven配置阿里云镜像仓库
  17. 线程池ThreadPoolExecutor的一种扩展办法
  18. 小程序 js中获取时间new date()的用法(网络复制过来自用)
  19. Windows运行命令
  20. Ubuntu 16.04安装MySQL及遇到的问题解决方案

热门文章

  1. php 中的引用(&)与foreach结合后的一个注意点
  2. spring+redis 报错 org.springframework.core.serializer.support.DeserializingConverter.<init>(Ljava/lang/ClassLoader;)V
  3. [WOJ1318]和最大
  4. sql 语句操作,修改字段中字符串的一部分
  5. 为什么站点使用https加密之后还能看到相关数据
  6. 155 Min Stack 最小栈
  7. 如何正确从他人机器MySQL数据库下拷贝出.sql,再导入到自己windows下MySQL数据库(图文详解)
  8. log4j:WARN Please initialize the log4j system properly. 异常解决
  9. XSS漏洞解析(三)
  10. SQL 多字段去重