solr使用心得
/**
* @author zhipeng
* @date 创建时间:2015-10-10 下午12:15:35
* @parameter
* @return
*/
public class SolrServer {
private static SolrServer solrServer = null;
private static HttpSolrServer server=null;
private static Map<Object, Object> proMap = new HashMap<Object, Object>();
private static Logger log = Logger.getLogger(SolrServer.class);
public static synchronized SolrServer getInstance() {
if (solrServer==null){
solrServer=new SolrServer();
}
return solrServer;
}
static{
Properties properties = new Properties();
try {
properties.load(SolrServer.class
.getResource("/solrparams.properties").openStream());
} catch (IOException e) {
log.error("IOException has been cactched SolrServer solrparams.properties读取配置错误", e);
}
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
Object key = entry.getKey();
Object value = entry.getValue();
//log.debug("---> key :" +key +" : value" +value);
proMap.put(key, value);
}
}
public static HttpSolrServer getServer(String domain){
try {
if(server != null && server.getBaseURL() != null && server.getBaseURL().indexOf(domain)>0){
log.debug("加载solr的URL:"+server.getBaseURL());
}else{
String solrurl=(String) proMap.get("solrurl")+domain;
server = new HttpSolrServer(solrurl);
server.setSoTimeout(1000*60); // socket read timeout
server.setConnectionTimeout(1000*60); //1分钟的提交时间 防止提交超时
server.setDefaultMaxConnectionsPerHost(100);
server.setMaxTotalConnections(100);
server.setFollowRedirects(false); // defaults to false
//allowCompression defaults to false.
//Server side must support gzip or deflate for this to have any effect.
server.setAllowCompression(true);
server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
}
} catch (Exception e) {
log.debug("SolrServer getServer 获取solr服务错误"+e);
}
return server;
}
}
java 的工具类 solrUtil
springMVC 在bean 启动完后执行方法
达人 expert
@Service
public class ExpertServiceImpl implements IExpertService,
ApplicationListener<ContextRefreshedEvent> {
// 获取连接服务
@SuppressWarnings("static-access")
private static HttpSolrServer solrServer = SolrServer.getInstance()
.getServer();
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
Pagination page = new Pagination();
Map<String, Object> query = new HashMap<String, Object>();
//查询标识 expertId:* solr数据是否为空
query.put("expertId", "*");
List<Expert> expertList = searchExpertSolr(page,query);
if(expertList.size() <= 0){
//如果容器第一次启动
if (event.getApplicationContext().getParent() == null) {
List<ExpertPO> expertsList = interStorage.getExpertList();
for (ExpertPO experts : expertsList) {
SolrInputDocument doc1 = new SolrInputDocument();
Expert expert = ExpertModelUtil.expertPO2BO(experts);
writeExpertSolr(doc1,expert);
ExpertResume expertResume = ExpertModelUtil
.expertPO2ResumeBO(experts);
writeExpertResumeSolr(doc1,expertResume);
ExpertStore expertStore = ExpertModelUtil
.expertPO2StoreBO(experts);
doc1 = writeExpertStoreSolr(doc1,expertStore);
commitSolr(doc1);
}
}
}
}
/**
* 达人信息 写入到solr writerSolr()
*
* @param
* @return
* @author zhipeng
* @Time 2015-10-12 上午11:50:55
*/
private static SolrInputDocument writeExpertSolr(SolrInputDocument doc1,Expert expert) {
doc1.addField("id", expert.getUserId());
doc1.addField("userId", expert.getUserId());
doc1.addField("expertId", expert.getUserId());
doc1.addField("realName", expert.getRealName());
doc1.addField("mobile", expert.getMobile());
doc1.addField("showable", expert.getShowable());
doc1.addField("expertMeetCount", expert.getExpertMeetCount());
doc1.addField("email", expert.getEmail());
doc1.addField("expertGrade", expert.getExpertGrade());
doc1.addField("activityArea", expert.getActivityArea());
doc1.addField("institutions", expert.getInstitutions());
doc1.addField("relatedLinks", expert.getRelatedLinks());
doc1.addField("residentCity", expert.getResidentCity());
doc1.addField("position", expert.getPosition());
doc1.addField("publicAccount", expert.getPublicAccount());
doc1.addField("workingYears", expert.getWorkingYears());
doc1.addField("portrait", expert.getPortrait());
doc1.addField("auditFailReason", expert.getAuditFailReason());
doc1.addField("usableStatus", expert.getUsableStatus());
doc1.addField("auditStatus", expert.getAuditStatus());
doc1.addField("name", expert.getName());
doc1.addField("payType", expert.getPayType());
doc1.addField("payAccount", expert.getPayAccount());
doc1.addField("expertIdNumber", expert.getExpertIdNumber());
doc1.addField("expertCharge", expert.getExpertCharge());
return doc1;
}
/**
* 达人简介 写入到 solr writeExpertResumeSolr()
*
* @param
* @return
* @author zhipeng
* @Time 2015-10-12 下午2:17:14
*/
private static SolrInputDocument writeExpertResumeSolr(SolrInputDocument doc1,ExpertResume expertResume) {
doc1.addField("expertprofile", expertResume.getExpertprofile());
doc1.addField("topicDescription", expertResume.getTopicDescription());
return doc1;
}
/**
* 达人店铺 写入到solr writeExpertStoreSolr()
*
* @param
* @return
* @author zhipeng
* @Time 2015-10-12 下午2:21:45
*/
private static SolrInputDocument writeExpertStoreSolr(SolrInputDocument doc1,ExpertStore expertStore) {
doc1.addField("webBackground", expertStore.getWebBackground());
doc1.addField("appBackground", expertStore.getAppBackground());
doc1.addField("PersonalBackground", expertStore.getPersonalBackground());
doc1.addField("workTime", expertStore.getWorkTime());
doc1.addField("responseFrequency", expertStore.getResponseFrequency());
return doc1;
}
/**
* 提交solr commitSolr()
*
* @param
* @return
* @author zhipeng
* @Time 2015-10-12 下午6:15:34
*/
private static void commitSolr(SolrInputDocument doc1) {
try {
solrServer.add(doc1);
solrServer.commit();
} catch (SolrServerException | IOException e) {
log.debug(ExpertServiceImpl.class + "commitSolr()"+e);
}
}
/**
* 返回solr 查询的 结果集 getResponse()
* @param
* @return
* @author zhipeng
* @Time 2015-10-12 上午11:45:55
*/
private static QueryResponse getResponse(Pagination page, Map<String, Object> query) {
SolrQuery sQuery = new SolrQuery();
sQuery.setQuery(makeSearchQuery(query));
// 设置分页 PageNum=0就是从0开始,,size=5当前返回5条记录,第二页就是变化PageNum这个值为5就可以了。
sQuery.setStart((page.getPageNum() - 1) * page.getPageSize());
sQuery.setRows(page.getPageSize());
QueryResponse response = null;
try {
response = solrServer.query(sQuery);
} catch (SolrServerException e) {
log.debug(ExpertServiceImpl.class + "getResponse()" +e);
}
return response;
}
/**
* 构造solr 查询的条件参数
* makeSearchQuery()
* @param
* @return
* @author zhipeng
* @Time 2015-10-13 下午4:28:00
*/
private static String makeSearchQuery(Map<String, Object> query){
StringBuffer searchQuery = new StringBuffer();
if (query.containsKey("userId")) {
searchQuery.append("userId:" + query.get("userId"));
}
if (query.containsKey("realName")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND realName:" + query.get("realName"));
} else {
searchQuery.append("realName:" + query.get("realName"));
}
}
if (query.containsKey("mobile")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND mobile:" + query.get("mobile"));
} else {
searchQuery.append("mobile:" + query.get("mobile"));
}
}
if (query.containsKey("auditStatus")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND auditStatus:"+ query.get("auditStatus"));
} else {
searchQuery.append("auditStatus:" + query.get("auditStatus"));
}
}
if (query.containsKey("usableStatus")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND usableStatus:"+ query.get("usableStatus"));
} else {
searchQuery.append("usableStatus:" + query.get("usableStatus"));
}
}
if (query.containsKey("expertId")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND expertId:*");
} else {
searchQuery.append("expertId:*");
}
}
if (query.size() <= 0) {
searchQuery.append("*:*");
}
return searchQuery.toString();
}
@Override
public List<Expert> searchExpertSolr(Pagination page,
Map<String, Object> query) {
List<Expert> expertList = new ArrayList<Expert>();
QueryResponse response = getResponse(page, query);
SolrDocumentList list = response.getResults();
for (SolrDocument solrDocument : list) {
Expert expert = new Expert(solrDocument);
expertList.add(expert);
}
return expertList;
}
@Override
public List<ExpertResume> searchExpertResumeSolr(Pagination page,
Map<String, Object> query) {
QueryResponse response = getResponse(page, query);
List<ExpertResume> expertResumeList = new ArrayList<ExpertResume>();
SolrDocumentList list = response.getResults();
for (SolrDocument solrDocument : list) {
ExpertResume expertResume = new ExpertResume(solrDocument);
expertResumeList.add(expertResume);
}
return expertResumeList;
}
@Override
public List<ExpertStore> searchExpertStoreSolr(Pagination page,
Map<String, Object> query) {
QueryResponse response = getResponse(page, query);
List<ExpertStore> expertStoreList = new ArrayList<ExpertStore>();
SolrDocumentList list = response.getResults();
for (SolrDocument solrDocument : list) {
ExpertStore expertStore = new ExpertStore(solrDocument);
expertStoreList.add(expertStore);
}
return expertStoreList;
}
}
查询 topicId 的 solr 各种条件拼接
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
Pagination page = new Pagination();
Map<String, Object> query = new HashMap<String, Object>();
query.put("topicId","*");
List<Topic> topicList = searchTopicSolr(page, query);
if (topicList.size() <= 0) {
if (event.getApplicationContext().getParent() == null) {
List<TopicActivity> topicActivityList = topicDBStorage
.getTopicActivityList();
for (TopicActivity topicActivity : topicActivityList) {
SolrInputDocument doc1 = new SolrInputDocument();
Topic topic = TopicModelUtil
.topicActivity2Topic(topicActivity);
writeTopicSolr(doc1, topic);
ExpertActivity activity = TopicModelUtil.topicActivity2Activity(topicActivity);
writeActivitySolr(doc1, activity);
commitSolr(doc1);
}
}
}
}
/**
* 提交solr commitSolr()
*
* @param
* @return
* @author zhipeng
* @Time 2015-10-12 下午6:15:34
*/
public static void commitSolr(SolrInputDocument doc1) {
try {
solrServer.add(doc1);
solrServer.commit();
} catch (SolrServerException | IOException e) {
log.debug(TopicServiceImpl.class + "commitSolr()"+e);
}
}
/**
* 话题 写入 sol
* writeTopicSolr()
* @param
* @return
* @author zhipeng
* @Time 2015-10-14 上午10:09:48
*/
public static SolrInputDocument writeTopicSolr(SolrInputDocument doc1,Topic topic){
doc1.addField("id", topic.getId());
doc1.addField("topicId",topic.getId());
doc1.addField("title", topic.getTitle());
doc1.addField("content", topic.getContent());
doc1.addField("publisherId", topic.getPublisherId());
doc1.addField("publisher", topic.getPublisher());
doc1.addField("publishTime", topic.getPublishTime());
doc1.addField("price", topic.getPrice());
doc1.addField("keywords", topic.getKeywords());
doc1.addField("auditStatus", topic.getAuditStatus());
doc1.addField("activestatus", topic.getActivestatus());
doc1.addField("topicType", topic.getTopicType());
doc1.addField("requirement", topic.getRequirement());
doc1.addField("duration", topic.getDuration());
//doc1.addField("categoryIds", topic.getCategoryIds());
doc1.addField("sort", topic.getSort());
doc1.addField("collectionCount", topic.getCollectionCount());
doc1.addField("description", topic.getDescription());
doc1.addField("categoryIds",topic.getTopicCategoryIds());
return doc1;
}
public static SolrInputDocument writeActivitySolr(SolrInputDocument doc1,ExpertActivity activity){
doc1.addField("contant", activity.getContant());
doc1.addField("userCountUpper", activity.getUserCountUpper());
doc1.addField("userCountLower", activity.getUserCountLower());
doc1.addField("beginTime", activity.getBeginTime());
doc1.addField("endTime", activity.getEndTime());
doc1.addField("address", activity.getAddress());
doc1.addField("activityDescription", activity.getDescription());
doc1.addField("applyBeginTime", activity.getApplyBeginTime());
doc1.addField("applyEndTime", activity.getApplyEndTime());
return doc1;
}
/**
* 构造solr 查询的条件参数
* makeSearchQuery()
* @param
* @return
* @author zhipeng
* @Time 2015-10-13 下午4:28:00
*/
public static String makeSearchQuery(Map<String, Object> query){
StringBuffer searchQuery = new StringBuffer();
if(query.containsKey("id")){
searchQuery.append("id:" + query.get("id"));
}
if (query.containsKey("auditStatus")) {
if(StringUtils.isNotBlank(searchQuery.toString())){
searchQuery.append(" AND auditStatus:" + query.get("auditStatus"));
}else{
searchQuery.append("auditStatus:" + query.get("auditStatus"));
}
}
if(query.containsKey("activityStatus")){
if(StringUtils.isNotBlank(searchQuery.toString())){
searchQuery.append(" AND activityStatus:" + query.get("activityStatus"));
}else{
searchQuery.append("activityStatus:" + query.get("activityStatus"));
}
}
if (query.containsKey("title")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND title:"+"*" + query.get("title")+"*");
} else {
searchQuery.append("title:" +"*"+ query.get("title")+"*");
}
}
if (query.containsKey("publisher")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND publisher:"+"*"+query.get("publisher")+"*");
} else {
searchQuery.append("publisher:" +"*"+ query.get("publisher")+"*");
}
}
if (query.containsKey("publisherId")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND publisherId:" + query.get("publisherId"));
} else {
searchQuery.append("publisherId:" + query.get("publisherId"));
}
}
if (query.containsKey("topicType")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND topicType:" + query.get("topicType"));
} else {
searchQuery.append("topicType:" + query.get("topicType"));
}
}
if (query.containsKey("category")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND categoryIds:" + query.get("categoryIds"));
} else {
searchQuery.append("categoryIds:" + query.get("categoryIds"));
}
}
if (query.containsKey("keyword")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND ( title:*" + query.get("keyword")+"*");
searchQuery.append(" OR publisher:*" + query.get("keyword")+"*)");
} else {
searchQuery.append("title:*" + query.get("keyword")+"*");
searchQuery.append(" OR publisher:*" + query.get("keyword")+"*");
}
}
if (query.containsKey("topicId")) {
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND topicId:*");
} else {
searchQuery.append("topicId:*");
}
}
if(query.containsKey("publisherIdList")){
@SuppressWarnings("unchecked")
List<Long> userIdList = (List<Long>) query.get("publisherIdList");
for (int i = 0; i < userIdList.size(); i++) {
if(i != 0){
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" OR publisherId:"+userIdList.get(i));
}
}else{
if (StringUtils.isNotBlank(searchQuery.toString())) {
searchQuery.append(" AND ( publisherId:"+userIdList.get(i));
}else{
searchQuery.append(" ( publisherId:"+userIdList.get(i));
}
}
}
searchQuery.append(" )");
}
if (query.size() <= 0) {
searchQuery.append("*:*");
}
return searchQuery.toString();
}
/**
* 返回solr 查询的 结果集 getResponse() find 排序
* @param
* @return
* @author zhipeng
* @Time 2015-10-12 上午11:45:55
*/
public static QueryResponse getFindResponse(Pagination page,Map<String,Object> query) {
SolrQuery sQuery = new SolrQuery();
sQuery.setQuery(makeSearchQuery(page.getQuery()));
// 设置分页 PageNum=0就是从0开始,,size=5当前返回5条记录,第二页就是变化PageNum这个值为5就可以了。
sQuery.setStart((page.getPageNum() - 1) * page.getPageSize());
sQuery.setRows(page.getPageSize());
if(query!=null){
if(query.containsKey("sort")){
sQuery.addSort(new SortClause("publishTime",ORDER.desc));
}else{
sQuery.addSort(new SortClause("sort",ORDER.asc));
sQuery.addSort(new SortClause("publishTime",ORDER.desc));
sQuery.addSort(new SortClause("auditStatus",ORDER.asc));
}
}
QueryResponse response = null;
try {
response = solrServer.query(sQuery);
} catch (SolrServerException e) {
log.debug(TopicServiceImpl.class + "getResponse()" +e);
}
return response;
}
/**
* 返回solr 查询的 结果集 getResponse() findByCategory 排序
* @param
* @return
* @author zhipeng
* @Time 2015-10-12 上午11:45:55
*/
public static QueryResponse getResponse(Pagination page,Map<String,Object> query) {
SolrQuery sQuery = new SolrQuery();
Map<String,Object> pageQuery=page.getQuery();
pageQuery.put("topicId", query.get("topicId"));
sQuery.setQuery(makeSearchQuery(page.getQuery()));
// 设置分页 PageNum=0就是从0开始,,size=5当前返回5条记录,第二页就是变化PageNum这个值为5就可以了。
sQuery.setStart((page.getPageNum() - 1) * page.getPageSize());
sQuery.setRows(page.getPageSize());
if(query!=null){
if(query.containsKey("sortBy")){
int sortIndex =Integer.parseInt(query.get("sortBy").toString());
String sortType="";
if(query.containsKey("sort")){
sortType =query.get("sort").toString();
}
//默认排序
if(sortIndex==1){
sQuery.addSort(new SortClause("sort",ORDER.asc));
sQuery.addSort(new SortClause("publishtime",ORDER.desc));
}
//收藏数量排序
else if(sortIndex == 2){
if(StringUtils.isBlank(sortType)){
sortType ="asc";
}
if("asc".equals(sortType)){
sQuery.addSort(new SortClause("collectioncount",ORDER.asc));
}else{
sQuery.addSort(new SortClause("collectioncount",ORDER.desc));
}
}
//根据创建时间
else if(sortIndex ==3){
if(StringUtils.isBlank(sortType)){
sortType ="desc";
}
if("desc".equals(sortType)){
sQuery.addSort(new SortClause("publishtime",ORDER.desc));
}else{
sQuery.addSort(new SortClause("publishtime",ORDER.asc));
}
}
//价格排序
else if(sortIndex==4){
if(StringUtils.isBlank(sortType)){
sortType ="asc";
}
if("asc".equals(sortType)){
sQuery.addSort(new SortClause("price",ORDER.asc));
}else{
sQuery.addSort(new SortClause("price",ORDER.desc));
}
}
}
}
QueryResponse response = null;
try {
response = solrServer.query(sQuery);
} catch (SolrServerException e) {
log.debug(TopicServiceImpl.class + "getResponse()" +e);
}
return response;
}
public static List<Topic> searchTopicSolr(Pagination page,Map<String,Object> query){
QueryResponse response = getResponse(page,query);
List<Topic> topicList = new ArrayList<Topic>();
SolrDocumentList list = response.getResults();
for (SolrDocument solrDocument : list) {
Topic topic = new Topic(solrDocument);
ExpertActivity activity = new ExpertActivity(solrDocument);
topic.setExpertActivity(activity);
topic.setUserCount(activity.getUserCountLower()+"--"+activity.getUserCountUpper());
topicList.add(topic);
}
return topicList;
}
public static List<Topic> searchTopicFindSolr(Pagination page,Map<String,Object> query){
QueryResponse response = getFindResponse(page,query);
List<Topic> topicList = new ArrayList<Topic>();
SolrDocumentList list = response.getResults();
for (SolrDocument solrDocument : list) {
Topic topic = new Topic(solrDocument);
ExpertActivity activity = new ExpertActivity(solrDocument);
topic.setExpertActivity(activity);
topicList.add(topic);
}
return topicList;
}
public static List<ExpertActivity> searchActivitySolr(Pagination page,Map<String,Object> query){
QueryResponse response = getResponse(page,query);
List<ExpertActivity> activityList = new ArrayList<ExpertActivity>();
SolrDocumentList list = response.getResults();
for (SolrDocument solrDocument : list) {
ExpertActivity activity = new ExpertActivity(solrDocument);
activityList.add(activity);
}
return activityList;
}
solr使用心得的更多相关文章
- solr学习(一)安装与部署
经过测试,同步MongoDB数据到Solr的时候,Solr版本为8.4.0会出现连接不上的错误,8.3.0未经测试不知,博主测试好用的一版为8.2.0,但是官网已经下不到了,所以我会把下载链接放在文末 ...
- 关于Solr的使用总结的心得体会
摘要:在项目中使用Solr作为搜索引擎对大数据量创建索引,提供服务,本文是作者对Solr的使用总结的一点心得体会, 具体包括使用DataImportHandler从数据库中近实时同步数据.测试Solr ...
- 开源搜索引擎Solr的快速搭建及集成到企业门户最佳实施方案--转载
笔者经过研究查阅solr官方相关资料经过两周的研究实现了毫秒级百万数据的搜索引擎的搭建并引入到企业门户.现将实施心得和步骤分享一下. 1. jdk1.6 安装jdk1.6到系统默认目录下X: ...
- Solr的学习使用之(一)部署
Solr的主要功能是全文检索,该功能分为两个过程:创建索引和对索引进行搜索 一.心得体会 第一次写技术博客,这次写的基本上都是从网络上整理的来的,外加自己的一些实践,以后争取全部原创哈,都说写技术博客 ...
- solr服务中集成IKAnalyzer中文分词器、集成dataimportHandler插件
昨天已经在Tomcat容器中成功的部署了solr全文检索引擎系统的服务:今天来分享一下solr服务在海量数据的网站中是如何实现数据的检索. 在solr服务中集成IKAnalyzer中文分词器的步骤: ...
- 我的MYSQL学习心得(一) 简单语法
我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据类型 我的MYSQL学习心得(五) 运 ...
- NoSql数据库使用半年后在设计上面的一些心得
NoSql数据库这个概念听闻许久了,也陆续看到很多公司和产品都在使用,优缺点似乎都被分析的清清楚楚.但我心里一直存有一个疑惑,它的出现究竟是为了解决什么问题? 这个疑惑非常大,为此我看了很多分析文章, ...
- Solr 排除查询
前言 solr排除查询也就是我们在数据库和程序中经常处理的不等于,solr的语法是在定语前加[-].. StringBuilder sbHtml=new StringBuilder(); shBhtm ...
- Solr高级查询Facet
一.什么是facet solr种以导航为目的的查询结果成为facet,在用户查询的结果上根据分类增加了count信息,然后用户根据count信息做进一步搜索. facet主要用于导航实现渐进式精确搜索 ...
随机推荐
- iOS开发系列之性能优化(上)
本篇主要记录一下我对界面优化上的一些探索.关于时间优化的探索将会在中篇里进行介绍.下篇将主要介绍一些耗电优化.安装包瘦身的探索. ### 1.卡顿原理 要了解卡顿原理,需要对帧缓冲区.垂直同步.CPU ...
- Mac安装MySQL-python报错解决
Mac安装MySQL-pyhton报错 今天在Mac上安装MySQL-python报错,搜遍网络都说什么mysql config路径问题,但是都不行. 解决方案 一开始遇到的问题是: Complete ...
- Docker启动一个Centos镜像,在docker中安装ifconfig和ssh
执行docker search centos 现在最流行的Linux嘛.查了下,排名第一的(STARS最多1882)官方版,就是你了 果断拿下, docker pull centos,看网速了静等拿下 ...
- 总结关于CPU的一些基本知识
关于CPU和程序的执行 CPU是计算机的大脑. 程序的运行过程,实际上是程序涉及到的.未涉及到的一大堆的指令的执行过程. 当程序要执行的部分被装载到内存后,CPU要从内存中取出指令,然后指令解码(以便 ...
- Spring Boot 打包成的可执行 jar ,为什么不能被其他项目依赖?
前两天被人问到这样一个问题: "松哥,为什么我的 Spring Boot 项目打包成的 jar ,被其他项目依赖之后,总是报找不到类的错误?" 大伙有这样的疑问,就是因为还没搞清楚 ...
- django ORM中的RelatedManager(关联管理器)
关联管理器应用在 一对多的表 或者 多对多的表 多对多表中的用法: 在多对多的表中 正向查询 #基于对象的查询 #正查 # author_obj = Author.objects.get(id=1) ...
- ABP开发框架前后端开发系列---(15)ABP框架的服务端和客户端缓存的使用
缓存在一个大型一点的系统里面是必然会涉及到的,合理的使用缓存能够给我们的系统带来更高的响应速度.由于数据提供服务涉及到数据库的相关操作,如果客户端的并发数量超过一定的数量,那么数据库的请求处理则以爆发 ...
- C++中 / 和 % 在分离各位时的妙用
在学习c++的过程中,我们一般用 / 和 % 来分解数字的各个位 取整 (/) 比如1234 / 10 等于 123.4,这相当于把前三位分解出来了 取余(%) 比如 12345 的分解方法 个位:1 ...
- Akka-CQRS(16)- gRPC用JWT进行权限管理
前面谈过gRPC的SSL/TLS安全机制,发现设置过程比较复杂:比如证书签名:需要服务端.客户端两头都设置等.想想实际上用JWT会更加便捷,而且更安全和功能强大,因为除JWT的加密签名之外还可以把私密 ...
- pdfminer获取每页的layout
#! python2 # coding: utf-8 import sys from pdfminer import pdfparser from pdfminer import pdfdocumen ...