当前位置: 首页 > news >正文

网站 编程语言/百度竞价排名系统

网站 编程语言,百度竞价排名系统,天柱县住房和城乡建设部网站,网站建设横向发展纵向发展为了减轻项目的中间件臃肿,由于我们项目本身就应用了 Redis,正好 Redis 的也具备订阅发布监听的特性,正好应对 Etcd 的功能,所以本次给大家讲解如何使用 Redis 消息订阅发布来替代 Etcd 的解决方案。接下来,我们先看 R…

为了减轻项目的中间件臃肿,由于我们项目本身就应用了 Redis,正好 Redis 的也具备订阅发布监听的特性,正好应对 Etcd 的功能,所以本次给大家讲解如何使用 Redis 消息订阅发布来替代 Etcd 的解决方案。接下来,我们先看 Redis 订阅发布的常见情景……

Redis 订阅发布公共类

RedisConfig.java
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.net.UnknownHostException;@Configuration
@ComponentScan({"cn.hutool.extra.spring"})
public class RedisConfig {@BeanRedisMessageListenerContainer container (RedisConnectionFactory redisConnectionFactory){RedisMessageListenerContainer container = new RedisMessageListenerContainer();container.setConnectionFactory(redisConnectionFactory);return  container;}@Beanpublic RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {RedisTemplate<String, Object> template = new RedisTemplate();// 连接工厂template.setConnectionFactory(redisConnectionFactory);// 序列化配置Jackson2JsonRedisSerializer objectJackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);ObjectMapper objectMapper = new ObjectMapper();objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);objectJackson2JsonRedisSerializer.setObjectMapper(objectMapper);StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();// 配置具体序列化// key采用string的序列化方式template.setKeySerializer(stringRedisSerializer);// hash的key采用string的序列化方式template.setHashKeySerializer(stringRedisSerializer);// value序列化采用jacksontemplate.setValueSerializer(objectJackson2JsonRedisSerializer);// hash的value序列化采用jacksontemplate.setHashValueSerializer(objectJackson2JsonRedisSerializer);template.afterPropertiesSet();return template;}
}
RedisUtil.java
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;@Slf4j
@Component
public class RedisUtil {@Resourceprivate RedisTemplate redisTemplate;/*** 消息发送* @param topic 主题* @param message 消息*/public void publish(String topic, String message) {redisTemplate.convertAndSend(topic, message);}
}
application.yml
server:port: 7077
spring:application:name: redis-demoredis:host: localhosttimeout: 3000jedis:pool:max-active: 300max-idle: 100max-wait: 10000port: 6379
RedisController.java
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;/*** @author Lux Sun* @date 2023/9/12*/
@RestController
@RequestMapping("/redis")
public class RedisController {@Resourceprivate RedisUtil redisUtil;@PostMappingpublic String publish(@RequestParam String topic, @RequestParam String msg) {redisUtil.publish(topic, msg);return "发送成功: " + topic + " - " + msg;}
}

一、业务情景:1 个消费者监听 1 个 Topic

教程三步走(下文业务情景类似不再描述)
  1. 实现接口 MessageListener
  2. 消息订阅,绑定业务 Topic
  3. 重写 onMessage 消费者业务方法
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;@Slf4j
@Component
public class RedisReceiver1 implements MessageListener {@Resourceprivate RedisMessageListenerContainer container;/*** 重点关注这方法, 进行消息订阅*/@PostConstructpublic void init() {MessageListenerAdapter adapter = new MessageListenerAdapter(this);// 绑定 Topic 语法为正则表达式container.addMessageListener(adapter, new PatternTopic("topic1.*"));}@Overridepublic void onMessage(Message message, byte[] bytes) {String key = new String(message.getChannel());String value = new String(message.getBody());log.info("Key: {}", key);log.info("Value: {}", value);}
}
测试
curl --location '127.0.0.1:7077/redis' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'topic=topic1.msg' \
--data-urlencode 'msg=我是消息1'
结果
2023-11-15 10:22:38.445  INFO 59189 --- [    container-2] com.xxx.redis.demo.RedisReceiver1  : Key: topic1.msg
2023-11-15 10:22:38.445  INFO 59189 --- [    container-2] com.xxx.redis.demo.RedisReceiver1  : Value: "我是消息1"

二、业务情景:1 个消费者监听 N 个 Topic

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;@Slf4j
@Component
public class RedisReceiver1 implements MessageListener {@Resourceprivate RedisMessageListenerContainer container;/*** 重点关注这方法, 进行消息订阅*/@PostConstructpublic void init() {MessageListenerAdapter adapter = new MessageListenerAdapter(this);// 绑定 Topic 语法为正则表达式container.addMessageListener(adapter, new PatternTopic("topic1.*"));// 只需再绑定业务 Topic 即可container.addMessageListener(adapter, new PatternTopic("topic2.*"));}@Overridepublic void onMessage(Message message, byte[] bytes) {String key = new String(message.getChannel());String value = new String(message.getBody());log.info("Key: {}", key);log.info("Value: {}", value);}
}
测试
curl --location '127.0.0.1:7077/redis' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'topic=topic2.msg' \
--data-urlencode 'msg=我是消息2'
结果
2023-11-15 10:22:38.445  INFO 59189 --- [    container-2] com.xxx.redis.demo.RedisReceiver1  : Key: topic2.msg
2023-11-15 10:22:38.445  INFO 59189 --- [    container-2] com.xxx.redis.demo.RedisReceiver1  : Value: "我是消息2"

三、业务情景:N 个消费者监听 1 个 Topic

我们看一下,现在又新增一个 RedisReceiver2,按理讲测试的时候,RedisReceiver1 和 RedisReceiver2 会同时收到消息

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;@Slf4j
@Component
public class RedisReceiver2 implements MessageListener {@Resourceprivate RedisMessageListenerContainer container;/*** 重点关注这方法, 进行消息订阅*/@PostConstructpublic void init() {MessageListenerAdapter adapter = new MessageListenerAdapter(this);// 绑定 Topic 语法为正则表达式container.addMessageListener(adapter, new PatternTopic("topic1.*"));}@Overridepublic void onMessage(Message message, byte[] bytes) {String key = new String(message.getChannel());String value = new String(message.getBody());log.info("Key: {}", key);log.info("Value: {}", value);}
}
测试
curl --location '127.0.0.1:7077/redis' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'topic=topic1.msg' \
--data-urlencode 'msg=我是消息1'
结果
2023-11-15 10:22:38.445  INFO 59189 --- [    container-2] com.xxx.redis.demo.RedisReceiver1  : Key: topic1.msg
2023-11-15 10:22:38.449  INFO 59189 --- [    container-3] com.xxx.redis.demo.RedisReceiver2  : Key: topic1.msg
2023-11-15 10:22:38.545  INFO 59189 --- [    container-2] com.xxx.redis.demo.RedisReceiver1  : Value: "我是消息1"
2023-11-15 10:22:38.645  INFO 59189 --- [    container-3] com.xxx.redis.demo.RedisReceiver2  : Value: "我是消息1"

四、业务情景:N 个消费者监听 N 个 Topic

都到这阶段了,应该不难理解了吧~

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;@Slf4j
@Component
public class RedisReceiver2 implements MessageListener {@Resourceprivate RedisMessageListenerContainer container;/*** 重点关注这方法, 进行消息订阅*/@PostConstructpublic void init() {MessageListenerAdapter adapter = new MessageListenerAdapter(this);// 绑定 Topic 语法为正则表达式container.addMessageListener(adapter, new PatternTopic("topic1.*"));// 只需再绑定业务 Topic 即可container.addMessageListener(adapter, new PatternTopic("topic2.*"));}@Overridepublic void onMessage(Message message, byte[] bytes) {String key = new String(message.getChannel());String value = new String(message.getBody());log.info("Key: {}", key);log.info("Value: {}", value);}
}
测试
curl --location '127.0.0.1:7077/redis' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'topic=topic2.msg' \
--data-urlencode 'msg=我是消息2'
结果
2023-11-15 10:22:38.445  INFO 59189 --- [    container-2] com.xxx.redis.demo.RedisReceiver1  : Key: topic2.msg
2023-11-15 10:22:38.449  INFO 59189 --- [    container-3] com.xxx.redis.demo.RedisReceiver2  : Key: topic2.msg
2023-11-15 10:22:38.545  INFO 59189 --- [    container-2] com.xxx.redis.demo.RedisReceiver1  : Value: "我是消息2"
2023-11-15 10:22:38.645  INFO 59189 --- [    container-3] com.xxx.redis.demo.RedisReceiver2  : Value: "我是消息2"

好了,Redis 订阅发布的教程到此为止。接下来,我们看下如何用它来替代 Etcd 的业务情景?

这之前,我们先大概聊下 Etcd 的 2 个要点:

  1. Etcd 消息事件类型
  2. Etcd 持久层数据

那么问题来了,Redis 虽然具备基本的消息订阅发布,但是如何契合 Etcd 的这 2 点特性,我们目前给出对应的解决方案是:

  1. 使用 Redis K-V 的 value 作为 Etcd 消息事件类型
  2. 使用 MySQL 作为 Etcd 持久层数据:字段 id 随机 UUID、字段 key 对应 Etcd key、字段 value 对应 Etcd value,这样做的一个好处是无需重构数据结构
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;DROP TABLE IF EXISTS `t_redis_msg`;
CREATE TABLE `t_redis_msg` (
`id` varchar(32) NOT NULL,
`key` varchar(255) NOT NULL,
`value` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;SET FOREIGN_KEY_CHECKS = 1;

所以,如果想平替 Etcd 的事件类型和持久层数据的解决方案需要 MySQL & Redis 结合,接下来直接上代码……

Redis & MySQL 整合

application.yml(升级)
spring:application:name: redis-demodatasource:username: rootpassword: 123456url: jdbc:mysql://localhost:3306/db_demo?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghaidriver-class-name: com.mysql.cj.jdbc.Driverhikari:connection-test-query: SELECT 1idle-timeout: 40000max-lifetime: 1880000connection-timeout: 40000minimum-idle: 1validation-timeout: 60000maximum-pool-size: 20
RedisMsg.java
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;/*** @author Lux Sun* @date 2021/2/19*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "t_redis_msg", autoResultMap = true)
public class RedisMsg {@TableId(type = IdType.ASSIGN_UUID)private String id;@TableField(value = "`key`")private String key;private String value;
}
RedisMsgEnum.java
/*** @author Lux Sun* @date 2022/11/11*/
public enum RedisMsgEnum {PUT("PUT"),DEL("DEL");private String code;RedisMsgEnum(String code) {this.code = code;}public String getCode() {return code;}}
RedisMsgService.java
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;/*** @author Lux Sun* @date 2020/6/16*/
public interface RedisMsgService extends IService<RedisMsg> {/*** 获取消息* @param key*/RedisMsg get(String key);/*** 获取消息列表* @param key*/Map<String, String> map(String key);/*** 获取消息值* @param key*/String getValue(String key);/*** 获取消息列表* @param key*/List<RedisMsg> list(String key);/*** 插入消息* @param key* @param value*/void put(String key, String value);/*** 删除消息* @param key*/void del(String key);
}
RedisMsgServiceImpl.java
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;/*** @author Lux Sun* @date 2020/6/16*/
@Slf4j
@Service
public class RedisMsgServiceImpl extends ServiceImpl<RedisMsgDao, RedisMsg> implements RedisMsgService {@Resourceprivate RedisMsgDao redisMsgDao;@Resourceprivate RedisUtil redisUtil;/*** 获取消息** @param key*/@Overridepublic RedisMsg get(String key) {LambdaQueryWrapper<RedisMsg> lqw = new LambdaQueryWrapper<>();lqw.eq(RedisMsg::getKey, key);return redisMsgDao.selectOne(lqw);}/*** 获取消息列表** @param key*/@Overridepublic Map<String, String> map(String key) {List<RedisMsg> redisMsgs = this.list(key);return redisMsgs.stream().collect(Collectors.toMap(RedisMsg::getKey, RedisMsg::getValue));}/*** 获取消息值** @param key*/@Overridepublic String getValue(String key) {RedisMsg redisMsg = this.get(key);return redisMsg.getValue();}/*** 获取消息列表** @param key*/@Overridepublic List<RedisMsg> list(String key) {LambdaQueryWrapper<RedisMsg> lqw = new LambdaQueryWrapper<>();lqw.likeRight(RedisMsg::getKey, key);return redisMsgDao.selectList(lqw);}/*** 插入消息** @param key* @param value*/@Overridepublic void put(String key, String value) {log.info("开始添加 - key: {},value: {}", key, value);LambdaQueryWrapper<RedisMsg> lqw = new LambdaQueryWrapper<>();lqw.eq(RedisMsg::getKey, key);this.saveOrUpdate(RedisMsg.builder().key(key).value(value).build(), lqw);redisUtil.putMsg(key);log.info("添加成功 - key: {},value: {}", key, value);}/*** 删除消息** @param key*/@Overridepublic void del(String key) {log.info("开始删除 - key: {}", key);LambdaQueryWrapper<RedisMsg> lqw = new LambdaQueryWrapper<>();lqw.likeRight(RedisMsg::getKey, key);redisMsgDao.delete(lqw);redisUtil.delMsg(key);log.info("删除成功 - key: {}", key);}
}
RedisUtil.java(升级)
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;@Slf4j
@Component
public class RedisUtil {@Resourceprivate RedisTemplate redisTemplate;/*** 消息发送* @param topic 主题* @param message 消息*/public void publish(String topic, String message) {redisTemplate.convertAndSend(topic, message);}/*** 消息发送 PUT* @param topic 主题*/public void putMsg(String topic) {redisTemplate.convertAndSend(topic, RedisMsgEnum.PUT);}/*** 消息发送 DELETE* @param topic 主题*/public void delMsg(String topic) {redisTemplate.convertAndSend(topic, RedisMsgEnum.DEL);}
}

演示 DEMO

RedisMsgController.java
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;/*** @author Lux Sun* @date 2023/9/12*/
@RestController
@RequestMapping("/redisMsg")
public class RedisMsgController {@Resourceprivate RedisMsgService redisMsgService;@PostMappingpublic String publish(@RequestParam String topic, @RequestParam String msg) {redisMsgService.put(topic, msg);return "发送成功: " + topic + " - " + msg;}
}
RedisMsgReceiver.java
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;@Slf4j
@Component
public class RedisMsgReceiver implements MessageListener {@Resourceprivate RedisMsgService redisMsgService;@Resourceprivate RedisMessageListenerContainer container;@PostConstructpublic void init() {MessageListenerAdapter adapter = new MessageListenerAdapter(this);container.addMessageListener(adapter, new PatternTopic("topic3.*"));}@Overridepublic void onMessage(Message message, byte[] bytes) {String key = new String(message.getChannel());String event = new String(message.getBody());String value = redisMsgService.getValue(key);log.info("Key: {}", key);log.info("Event: {}", event);log.info("Value: {}", value);}
}
测试
curl --location '127.0.0.1:7077/redisMsg' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'topic=topic3.msg' \
--data-urlencode 'msg=我是消息3'
结果
2023-11-16 10:24:35.721  INFO 43794 --- [nio-7077-exec-1] c.c.redis.demo.RedisMsgServiceImpl       : 开始添加 - key: topic3.msg,value: 我是消息3
2023-11-16 10:24:35.935  INFO 43794 --- [nio-7077-exec-1] c.c.redis.demo.RedisMsgServiceImpl       : 添加成功 - key: topic3.msg,value: 我是消息3
2023-11-16 10:24:35.950  INFO 43794 --- [    container-2] c.xxx.redis.demo.RedisMsgReceiver  : Key: topic3.msg
2023-11-16 10:24:35.950  INFO 43794 --- [    container-2] c.xxx.redis.demo.RedisMsgReceiver  : Event: "PUT"
2023-11-16 10:24:35.950  INFO 43794 --- [    container-2] c.xxx.redis.demo.RedisMsgReceiver  : Value: 我是消息3

相关文章:

Redis - 订阅发布替换 Etcd 解决方案

为了减轻项目的中间件臃肿&#xff0c;由于我们项目本身就应用了 Redis&#xff0c;正好 Redis 的也具备订阅发布监听的特性&#xff0c;正好应对 Etcd 的功能&#xff0c;所以本次给大家讲解如何使用 Redis 消息订阅发布来替代 Etcd 的解决方案。接下来&#xff0c;我们先看 R…...

Hessian协议详解

前言 Hessian协议是一种基于二进制的轻量级远程调用协议&#xff0c;用于在分布式系统中进行跨语言的通信。它使用简单的二进制格式来序列化和反序列化数据&#xff0c;并支持多种编程语言&#xff0c;如Java、C#、Python等。Hessian协议相对于其他协议的优势在于其简单性和高…...

【AI视野·今日Sound 声学论文速览 第三十六期】Mon, 30 Oct 2023

AI视野今日CS.Sound 声学论文速览 Mon, 30 Oct 2023 Totally 7 papers &#x1f449;上期速览✈更多精彩请移步主页 Daily Sound Papers Style Description based Text-to-Speech with Conditional Prosodic Layer Normalization based Diffusion GAN Authors Neeraj Kumar, A…...

Android Jetpack的组件介绍,常见组件解析

jetpack组件有哪些 Android Jetpack是一个集成Android应用程序组件的一站式解决方案。它使开发人员能够专注于他们的应用程序的真正创新部分&#xff0c;而不会受到Android平台特定的限制。Jetpack组件可分为四个类别&#xff1a; 架构组件&#xff08;Architecture Componen…...

ImportError: cannot import name ‘url_quote‘ from...

&#x1f468;&#x1f3fb;‍&#x1f4bb; 热爱摄影的程序员 &#x1f468;&#x1f3fb;‍&#x1f3a8; 喜欢编码的设计师 &#x1f9d5;&#x1f3fb; 擅长设计的剪辑师 &#x1f9d1;&#x1f3fb;‍&#x1f3eb; 一位高冷无情的编码爱好者 大家好&#xff0c;我是全栈工…...

一文看分布式锁

为什么会存在分布式锁&#xff1f; 经典场景-扣库存&#xff0c;多人去同时购买一件商品&#xff0c;首先会查询判断是否有剩余&#xff0c;如果有进行购买并扣减库存&#xff0c;没有提示库存不足。假如现在仅存有一件商品&#xff0c;3人同时购买&#xff0c;三个线程同时执…...

Jenkins自动化部署一个Maven项目

Jenkins自动化部署 提示&#xff1a;本教程基于CentOS Linux 7系统下进行 Jenkins的安装 1. 下载安装jdk11 官网下载地址&#xff1a;https://www.oracle.com/cn/java/technologies/javase/jdk11-archive-downloads.html 本文档教程选择的是jdk-11.0.20_linux-x64_bin.tar.g…...

K8S1.23.5部署(此前1.17版本步骤囊括)及问题记录

应版本需求&#xff0c;升级容器版本为1.23.5 kubernetes组件 一个kubernetes集群主要由控制节点&#xff08;master&#xff09;与工作节点&#xff08;node&#xff09;组成&#xff0c;每个节点上需要安装不同的组件。 master控制节点&#xff1a;负责整个集群的管理。 …...

基于java web的中小型人力资源管理系统

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;Vue 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#xff1a;是 目录…...

Python学习笔记--Python关键字yield

原文:http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained 注:这是一篇 stackoverflow 上一个火爆帖子的译文 问题 Python 关键字 yield 的作用是什么?用来干什么的? 比如,我正在试图理解下面的代码: def node._get_child_candidates(self,…...

CF 850 C Arpa and a game with Mojtaba(爆搜优化SG)

CF 850 C. Arpa and a game with Mojtaba&#xff08;爆搜优化SG&#xff09; Problem - C - Codeforces Arpa and a game with Mojtaba - 洛谷 思路&#xff1a;显然对于每一种质因子来说操作都是独立的 &#xff0c; 因此可以考虑对于每一种质因子求当前质因子的SG &#…...

kafka分布式安装部署

1.集群规划 2.集群部署 官方下载地址&#xff1a;http://kafka.apache.org/downloads.html &#xff08;1&#xff09;上传并解压安装包 [zhangflink9wmwtivvjuibcd2e package]$ tar -zxvf kafka_2.12-3.3.1.tgz -C ../software/&#xff08;2&#xff09;修改解压后的文件…...

[云原生2.] Kurbernetes资源管理 ---- (陈述式资源管理方式)

文章目录 1. K8s管理资源的方法类别1.1 陈述式资源管理方式1.2 声明式资源管理方式1.3 GUI式资源管理方法 2. 陈述式资源管理方式2.1 命令行工具 ---- Kubelet2.1.1 简介2.1.2 特性2.1.3 kubelet拓展命令2.1.4 kubectl基本语法2.1.5 Kubectl工具的自动补全 2.2 k8s Service 的类…...

java:IDEA中的Scratches and Consoles

背景 IntelliJ IDEA中的Scratches and Consoles是一种临时的文件编辑环境&#xff0c;用于写一些文本内容或者代码片段。 其中&#xff0c;Scratch files拥有完整的运行和debug功能&#xff0c;这些文件需要指定编程语言类型并且指定后缀。 举例&#xff1a;调接口 可以看到…...

华为 Mate 60 Pro 拆解:陆制零件比率上升至47% | 百能云芯

近日&#xff0c;日经新闻联合研究公司Fomalhaut Techno Solutions对华为 Mate 60 Pro 进行了拆解&#xff0c;揭示了这款于8月发布的新型智能手机的成本结构。拆解结果显示&#xff0c;该手机的国产零部件比例达到了47%&#xff0c;相较于三年前的 Mate 40 Pro&#xff0c;提高…...

ZBrush 2024(三维数字雕刻软件)

ZBrush是一款Mac数字雕刻软件&#xff0c;它具有以下功能&#xff1a; 雕刻工具&#xff1a;ZBrush的雕刻工具非常强大&#xff0c;可以让用户在3D模型上进行雕刻&#xff0c;就像使用传统雕塑工具一样。高精度模型创建&#xff1a;ZBrush可以创建高精度的3D模型&#xff0c;适…...

wpf devexpress 排序、分组、过滤数据

这个教程示范在GridControl如何排序数据&#xff0c;分组数据给一个行创建一个过滤。这个教程基于前一个教程。 排序数据 可以使用GridControl 排序数据。这个例子如下过滤数据对于Order Date 和 Customer Id 行&#xff1a; 1、对于Order Date 和 Customer Id 行指定Colum…...

使用Badboy录制生成 JMeter 脚本

JMeter是一款在国外非常流行和受欢迎的开源性能测试工具&#xff0c;像LoadRunner 一样&#xff0c;它也提供了一个利用本地Proxy Server&#xff08;代理服务器&#xff09;来录制生成测试脚本的功能&#xff0c;但是这个功能并不好用。所以在本文中介绍一个更为常用的方法——…...

V10 桌面版、服务器版系统加固

V10 桌面版、服务器版系统加固 一、 文档说明 本文档中涉及的加固方法主要包括&#xff1a;密码策略配置、防火墙规 则配置、禁用高风险服务等。 二、 V10 桌面版系统加固 2.1 密码策略配置 密码策略包括密码老化控制策略和密码复杂度策略。密码老化 控制策略需要配置/etc…...

mtgsig1.2简单分析

{"a1": "1.2", # 加密版本"a2": new Date().valueOf() - serverTimeDiff, # 加密过程中用到的时间戳. 这次服主变坏了, 时间戳需要减去一个 serverTimeDiff(见a3) ! "a3": "这是把xxx信息加密后提交给服务器, 服主…...

场景交互与场景漫游-osgGA库(5)

osgGA库 osgGA库是OSG的一个附加的工具库&#xff0c;它为用户提供各种事件处理及操作处理。通过osgGA库读者可以像控制Windows窗口一样来处理各种事件 osgGA的事件处理器主要由两大部分组成&#xff0c;即事件适配器和动作适配器。osgGA:GUIEventHandler类主要提供了窗口系统的…...

Leetcode -1

Leetcode Leetcode -521.最长特殊序列Leetcode - 541.反转字符串Ⅱ Leetcode -521.最长特殊序列 题目&#xff1a;给你两个字符串 a 和 b&#xff0c;请返回 这两个字符串中 最长的特殊序列的长度。如果不存在&#xff0c;则返回 - 1 。 「最长特殊序列」 定义如下&#xff1…...

系列四、JVM的内存结构【本地接口(Native Interface)】

一、组成 本地接口由本地方法栈&#xff08;Native Method Stack&#xff09;、本地方法接口&#xff08;Native Interface&#xff09;、本地方法库组成。 二、本地接口的作用 本地接口的作用是融合不同的编程语言为Java所用&#xff0c;它的初衷是融合C/C程序&#xff0c;Jav…...

大型语言模型中的幻觉研究综述:原理、分类、挑战和未决问题11.15+11.16+11.17

大型语言模型中的幻觉研究综述&#xff1a;原理、分类、挑战和未决问题11.15 摘要1 引言2 定义2.1 LLM2.3 大语言模型中的幻觉 3 幻觉的原因3.1 数据的幻觉3.1.1 有缺陷的数据源3.1.2 较差的数据利用率3.1.3 摘要 3.2 来自训练的幻觉3.2.1训练前的幻觉3.2.2来自对齐的幻觉3.2.3…...

redis悲观锁和乐观锁

redis悲观锁 Redis加锁命令分有INCR、SETNX、SET 一、INCR锁 key不存在时&#xff0c;key的值会先被初始化为0&#xff0c;其它用户在执行INCR操作进行加一&#xff0c; 如果返回的数大于1&#xff0c;说明这个锁正在被使用当中&#xff0c;通常用在同时只能有一个人可以操作某…...

前端项目练习,首页退出登录功能,清除token --点击事件 quitFn

<el-menu-item index"2" click"quitFn"><i class"el-icon-switch-button">退出</i> </el-menu-item>quitFn() {// 为了让用户体验更好&#xff0c;来个确认提示框this.$confirm("确认退出登录吗&#xff1f;退出登…...

nodejs+vue杰和牧场管理系统的设计与实现-微信小程序-安卓-python-PHP-计算机毕业设计

系统涉及的对象是奶牛。 系统使用员工有管理员和普通员工。 管理员有修改的权限&#xff0c;普通员工没有。系统包含新闻功能&#xff0c;最好是有个后台管理&#xff0c;在后台输入新闻标题和内容&#xff0c;插入图片&#xff0c;在网页上就可以展示。最好再有个轮播图。 新闻…...

基于STM32的蓝牙低功耗(BLE)通信方案设计与实现

蓝牙低功耗&#xff08;Bluetooth Low Energy&#xff0c;简称BLE&#xff09;是一种能够在低功耗环境下实现无线通信的技术。在物联网应用中&#xff0c;BLE被广泛应用于传感器数据采集、健康监测设备、智能家居等领域。本文将基于STM32微控制器&#xff0c;设计并实现一个简单…...

qt 重载信号,使用““方式进行connect()调用解决方案

问题 在Qt中&#xff0c;重载的信号默认是无法使用&这种方式调用的。 因为&只能绑定到一个具体的信号&#xff0c;而重载的信号名称相同&#xff0c;编译器无法确定要绑定哪一个信号。 解决方案 如果非要使用&绑定重载的信号&#xff0c;可以使用函数指针进行转…...

阿里云+宝塔部署项目(Java+React)

阿里云服务器宝塔面板部署项目&#xff08;SpringBoot React&#xff09; 1. 上传所需的文件到服务器 比如jdk包和java项目的jar&#xff1a;这里以上传jar 为例&#xff0c;创建文件夹&#xff0c;上传文件&#xff1b; 在创建的文件夹下上传jar包 上传jdk 2. 配置jdk环境 3.…...