SpringBoot中动态注册接口
1. 说明
- 接口注册,使用RequestMappingHandlerMapping来实现
- mybatis中动态执行sql使用github上的SqlMapper工具类实现
2. 核心代码片段
以下代码为spring动态注册接口代码示例
@Autowired
private RequestMappingHandlerMapping requestMappingHandlerMapping;public boolean register2Spring(String path) {RequestMappingInfo requestMappingInfo = RequestMappingInfo.paths(path).methods(RequestMethod.POST).produces(MediaType.APPLICATION_JSON_VALUE).options(requestMappingHandlerMapping.getBuilderConfiguration()).build();Method method = ReflectionUtils.findMethod(getClass(), "handler",HttpServletRequest.class, HttpServletResponse.class,Map.class, Map.class, Map.class);boolean status = true;try {requestMappingHandlerMapping.registerMapping(requestMappingInfo, this, method);LOGGER.info("【接口注册成功】{}", path);} catch (Exception e) {status = false;LOGGER.error("【注册接口异常】动态映射失败", e.getMessage());}return status;}
3. 源码
3.1 核心代码
3.1.1 ApiServiceHandler
handler中register职责如下:
- 注册到数据库中
- 注册接口到spring容器中
import com.alibaba.fastjson2.JSONObject;
import com.google.common.net.HttpHeaders;
import com.hz.pro.artifact.bean.CommonException;
import com.hz.pro.artifact.bean.Response;
import com.hz.pro.artifact.dynamic.bean.ServiceDto;
import com.hz.pro.artifact.dynamic.mapper.main.ApiServiceMapper;
import com.hz.pro.artifact.utils.SqlMapper;
import org.apache.ibatis.session.SqlSessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;/*** @author pp_lan* @date 2024/1/4*/
@Service
public class ApiServiceHandler {private static final Logger LOGGER = LoggerFactory.getLogger(ApiServiceHandler.class);@Autowiredprivate RequestMappingHandlerMapping requestMappingHandlerMapping;@Autowired@Qualifier("sqlSessionFactory")private SqlSessionFactory sqlSessionFactory;@Autowiredprivate ApiServiceMapper apiServiceMapper;public void initialRegister() {List<ServiceDto> apis = findApis();for (ServiceDto api : apis) {try {register2Spring(api.getPath());} catch (Exception e) {LOGGER.error("[接口注册失败]{}", api.getPath(), e.getMessage());}}}/*** 注册到spring,并添加到数据库中** @param path* @param sql* @return*/public boolean register(String path, String sql) {boolean status = this.registerApiOfSql(path, sql);if (status) {status = register2Spring(path);}return status;}/*** 注册到容器** @param path* @return*/public boolean register2Spring(String path) {RequestMappingInfo requestMappingInfo = RequestMappingInfo.paths(path).methods(RequestMethod.POST).produces(MediaType.APPLICATION_JSON_VALUE).options(requestMappingHandlerMapping.getBuilderConfiguration()).build();Method method = ReflectionUtils.findMethod(getClass(), "handler",HttpServletRequest.class, HttpServletResponse.class,Map.class, Map.class, Map.class);boolean status = true;try {requestMappingHandlerMapping.registerMapping(requestMappingInfo, this, method);LOGGER.info("【接口注册成功】{}", path);} catch (Exception e) {status = false;LOGGER.error("【注册接口异常】动态映射失败", e.getMessage());}return status;}@ResponseBodypublic Response handler(HttpServletRequest request, HttpServletResponse response,@PathVariable(required = false) Map<String, Object> pathVariable,@RequestParam(required = false) Map<String, Object> requestParam,@RequestBody(required = false) Map<String, Object> requestBody) {String header = request.getHeader(HttpHeaders.CONTENT_TYPE);// 参数处理JSONObject params;if (header != null && header.contains(MediaType.APPLICATION_JSON_VALUE)) {params = new JSONObject(requestBody);} else {params = new JSONObject(requestParam);}// 执行查询try (SqlMapper sqlMapper = new SqlMapper(sqlSessionFactory)) {String path = request.getRequestURI();String sql = apiServiceMapper.findSqlByPath(path);List<Map<String, Object>> result = sqlMapper.selectList(sql, params);return Response.ok(result);} catch (Exception e) {throw new CommonException("【公共查询异常】", e);}}/*** 查询所有在用接口** @return*/public List<ServiceDto> findApis() {return apiServiceMapper.findApis();}/*** 注册接口** @param path* @param sql* @return*/public boolean registerApiOfSql(String path, String sql) {try {return apiServiceMapper.insertApiSql(path, sql) > 0;} catch (Exception e) {throw new CommonException("【注册接口异常】插入sql配置失败", e);}}}
3.1.2 DynamicController
手动注册接口执行/dynamic/register方法,便可以完成接口注册。
import com.hz.pro.artifact.bean.Response;
import com.hz.pro.artifact.dynamic.bean.ApiReq;
import com.hz.pro.artifact.dynamic.service.ApiServiceHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** @author pp_lan* @date 2024/1/2*/
@RestController
@RequestMapping("/dynamic")
public class DynamicController {@Autowiredprivate ApiServiceHandler apiServiceHandler;/*** 注册接口** @param apiReq* @return*/@PostMapping("register")public Response register(@RequestBody @Validated ApiReq apiReq) {boolean registerStatus = apiServiceHandler.register(apiReq.getPath(), apiReq.getSql());return registerStatus ? Response.ok("接口注册成功") : Response.error("接口注册失败");}
}
3.2 依赖类
3.2.1 SqlMapper
此为github上有开源工具类,最新代码请移步github。以下为其源码:
import org.apache.ibatis.builder.StaticSqlSource;
import org.apache.ibatis.exceptions.TooManyResultsException;
import org.apache.ibatis.mapping.*;
import org.apache.ibatis.scripting.LanguageDriver;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;import java.util.ArrayList;
import java.util.List;
import java.util.Map;/*** MyBatis执行sql工具,在写SQL的时候建议使用参数形式的可以是${}或#{}** 不建议将参数直接拼到字符串中,当大量这么使用的时候由于缓存MappedStatement而占用更多的内存** @author liuzh* @since 2015-03-10*/
public class SqlMapper implements AutoCloseable {private final MSUtils msUtils;private final SqlSession sqlSession;/*** 构造方法,默认缓存MappedStatement** @param sqlSession*/public SqlMapper(SqlSession sqlSession) {this.sqlSession = sqlSession;this.msUtils = new MSUtils(sqlSession.getConfiguration());}public SqlMapper(SqlSessionFactory sqlSessionFactory) {this.sqlSession = sqlSessionFactory.openSession();this.msUtils = new MSUtils(sqlSession.getConfiguration());}/*** 获取List中最多只有一个的数据** @param list List结果* @param <T> 泛型类型* @return*/private <T> T getOne(List<T> list) {if (list.size() == 1) {return list.get(0);} else if (list.size() > 1) {throw new TooManyResultsException("Expected one result (or null) to be returned by selectOne(), but found: " + list.size());} else {return null;}}/*** 查询返回一个结果,多个结果时抛出异常** @param sql 执行的sql* @return*/public Map<String, Object> selectOne(String sql) {List<Map<String, Object>> list = selectList(sql);return getOne(list);}/*** 查询返回一个结果,多个结果时抛出异常** @param sql 执行的sql* @param value 参数* @return*/public Map<String, Object> selectOne(String sql, Object value) {List<Map<String, Object>> list = selectList(sql, value);return getOne(list);}/*** 查询返回一个结果,多个结果时抛出异常** @param sql 执行的sql* @param resultType 返回的结果类型* @param <T> 泛型类型* @return*/public <T> T selectOne(String sql, Class<T> resultType) {List<T> list = selectList(sql, resultType);return getOne(list);}/*** 查询返回一个结果,多个结果时抛出异常** @param sql 执行的sql* @param value 参数* @param resultType 返回的结果类型* @param <T> 泛型类型* @return*/public <T> T selectOne(String sql, Object value, Class<T> resultType) {List<T> list = selectList(sql, value, resultType);return getOne(list);}/*** 查询返回List<Map<String, Object>>** @param sql 执行的sql* @return*/public List<Map<String, Object>> selectList(String sql) {String msId = msUtils.select(sql);return sqlSession.selectList(msId);}/*** 查询返回List<Map<String, Object>>** @param sql 执行的sql* @param value 参数* @return*/public List<Map<String, Object>> selectList(String sql, Object value) {Class<?> parameterType = value != null ? value.getClass() : null;String msId = msUtils.selectDynamic(sql, parameterType);return sqlSession.selectList(msId, value);}/*** 查询返回指定的结果类型** @param sql 执行的sql* @param resultType 返回的结果类型* @param <T> 泛型类型* @return*/public <T> List<T> selectList(String sql, Class<T> resultType) {String msId;if (resultType == null) {msId = msUtils.select(sql);} else {msId = msUtils.select(sql, resultType);}return sqlSession.selectList(msId);}/*** 查询返回指定的结果类型** @param sql 执行的sql* @param value 参数* @param resultType 返回的结果类型* @param <T> 泛型类型* @return*/public <T> List<T> selectList(String sql, Object value, Class<T> resultType) {String msId;Class<?> parameterType = value != null ? value.getClass() : null;if (resultType == null) {msId = msUtils.selectDynamic(sql, parameterType);} else {msId = msUtils.selectDynamic(sql, parameterType, resultType);}return sqlSession.selectList(msId, value);}/*** 插入数据** @param sql 执行的sql* @return*/public int insert(String sql) {String msId = msUtils.insert(sql);return sqlSession.insert(msId);}/*** 插入数据** @param sql 执行的sql* @param value 参数* @return*/public int insert(String sql, Object value) {Class<?> parameterType = value != null ? value.getClass() : null;String msId = msUtils.insertDynamic(sql, parameterType);return sqlSession.insert(msId, value);}/*** 更新数据** @param sql 执行的sql* @return*/public int update(String sql) {String msId = msUtils.update(sql);return sqlSession.update(msId);}/*** 更新数据** @param sql 执行的sql* @param value 参数* @return*/public int update(String sql, Object value) {Class<?> parameterType = value != null ? value.getClass() : null;String msId = msUtils.updateDynamic(sql, parameterType);return sqlSession.update(msId, value);}/*** 删除数据** @param sql 执行的sql* @return*/public int delete(String sql) {String msId = msUtils.delete(sql);return sqlSession.delete(msId);}/*** 删除数据** @param sql 执行的sql* @param value 参数* @return*/public int delete(String sql, Object value) {Class<?> parameterType = value != null ? value.getClass() : null;String msId = msUtils.deleteDynamic(sql, parameterType);return sqlSession.delete(msId, value);}@Overridepublic void close() throws Exception {this.sqlSession.close();}private class MSUtils {private Configuration configuration;private LanguageDriver languageDriver;private MSUtils(Configuration configuration) {this.configuration = configuration;languageDriver = configuration.getDefaultScriptingLanuageInstance();}/*** 创建MSID** @param sql 执行的sql* @param sql 执行的sqlCommandType* @return*/private String newMsId(String sql, SqlCommandType sqlCommandType) {StringBuilder msIdBuilder = new StringBuilder(sqlCommandType.toString());msIdBuilder.append(".").append(sql.hashCode());return msIdBuilder.toString();}/*** 是否已经存在该ID** @param msId* @return*/private boolean hasMappedStatement(String msId) {return configuration.hasStatement(msId, false);}/*** 创建一个查询的MS** @param msId* @param sqlSource 执行的sqlSource* @param resultType 返回的结果类型*/private void newSelectMappedStatement(String msId, SqlSource sqlSource, final Class<?> resultType) {MappedStatement ms = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.SELECT).resultMaps(new ArrayList<ResultMap>() {{add(new ResultMap.Builder(configuration, "defaultResultMap", resultType, new ArrayList<ResultMapping>(0)).build());}}).build();//缓存configuration.addMappedStatement(ms);}/*** 创建一个简单的MS** @param msId* @param sqlSource 执行的sqlSource* @param sqlCommandType 执行的sqlCommandType*/private void newUpdateMappedStatement(String msId, SqlSource sqlSource, SqlCommandType sqlCommandType) {MappedStatement ms = new MappedStatement.Builder(configuration, msId, sqlSource, sqlCommandType).resultMaps(new ArrayList<ResultMap>() {{add(new ResultMap.Builder(configuration, "defaultResultMap", int.class, new ArrayList<ResultMapping>(0)).build());}}).build();//缓存configuration.addMappedStatement(ms);}private String select(String sql) {String msId = newMsId(sql, SqlCommandType.SELECT);if (hasMappedStatement(msId)) {return msId;}StaticSqlSource sqlSource = new StaticSqlSource(configuration, sql);newSelectMappedStatement(msId, sqlSource, Map.class);return msId;}private String selectDynamic(String sql, Class<?> parameterType) {String msId = newMsId(sql + parameterType, SqlCommandType.SELECT);if (hasMappedStatement(msId)) {return msId;}SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, parameterType);newSelectMappedStatement(msId, sqlSource, Map.class);return msId;}private String select(String sql, Class<?> resultType) {String msId = newMsId(resultType + sql, SqlCommandType.SELECT);if (hasMappedStatement(msId)) {return msId;}StaticSqlSource sqlSource = new StaticSqlSource(configuration, sql);newSelectMappedStatement(msId, sqlSource, resultType);return msId;}private String selectDynamic(String sql, Class<?> parameterType, Class<?> resultType) {String msId = newMsId(resultType + sql + parameterType, SqlCommandType.SELECT);if (hasMappedStatement(msId)) {return msId;}SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, parameterType);newSelectMappedStatement(msId, sqlSource, resultType);return msId;}private String insert(String sql) {String msId = newMsId(sql, SqlCommandType.INSERT);if (hasMappedStatement(msId)) {return msId;}StaticSqlSource sqlSource = new StaticSqlSource(configuration, sql);newUpdateMappedStatement(msId, sqlSource, SqlCommandType.INSERT);return msId;}private String insertDynamic(String sql, Class<?> parameterType) {String msId = newMsId(sql + parameterType, SqlCommandType.INSERT);if (hasMappedStatement(msId)) {return msId;}SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, parameterType);newUpdateMappedStatement(msId, sqlSource, SqlCommandType.INSERT);return msId;}private String update(String sql) {String msId = newMsId(sql, SqlCommandType.UPDATE);if (hasMappedStatement(msId)) {return msId;}StaticSqlSource sqlSource = new StaticSqlSource(configuration, sql);newUpdateMappedStatement(msId, sqlSource, SqlCommandType.UPDATE);return msId;}private String updateDynamic(String sql, Class<?> parameterType) {String msId = newMsId(sql + parameterType, SqlCommandType.UPDATE);if (hasMappedStatement(msId)) {return msId;}SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, parameterType);newUpdateMappedStatement(msId, sqlSource, SqlCommandType.UPDATE);return msId;}private String delete(String sql) {String msId = newMsId(sql, SqlCommandType.DELETE);if (hasMappedStatement(msId)) {return msId;}StaticSqlSource sqlSource = new StaticSqlSource(configuration, sql);newUpdateMappedStatement(msId, sqlSource, SqlCommandType.DELETE);return msId;}private String deleteDynamic(String sql, Class<?> parameterType) {String msId = newMsId(sql + parameterType, SqlCommandType.DELETE);if (hasMappedStatement(msId)) {return msId;}SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, parameterType);newUpdateMappedStatement(msId, sqlSource, SqlCommandType.DELETE);return msId;}}
}
3.2.2 ApiServiceMapper
import com.hz.pro.artifact.dynamic.bean.ServiceDto;
import org.apache.ibatis.annotations.Param;import java.util.List;/*** @author pp_lan* @date 2024/1/5*/
public interface ApiServiceMapper {List<ServiceDto> findApis();String findSqlByPath(@Param("path") String path);int insertApiSql(@Param("path") String path, @Param("sqlContent") String sqlContent);
}
3.2.3 ApiServiceMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hz.pro.artifact.dynamic.mapper.main.ApiServiceMapper"><select id="findApis" resultType="com.hz.pro.artifact.dynamic.bean.ServiceDto">select path, sql_content from t_api_sql where in_use = 1</select><select id="findSqlByPath" resultType="java.lang.String">select sql_content from t_api_sql where path = #{path} and in_use = 1</select><insert id="insertApiSql">INSERT INTO t_api_sql VALUES(#{path}, #{sqlContent}, 1)</insert></mapper>
4 效果
4.1 注册
4.2 查询
5. 其他
上述实现步骤已完成接口的注册、查询功能。但是存在一个问题,重启后接口便不存在了,需要重新初始化。后续可以使用监听读取数据库中接口配置进行接口的初始化。
相关文章:

SpringBoot中动态注册接口
1. 说明 接口注册,使用RequestMappingHandlerMapping来实现mybatis中动态执行sql使用github上的SqlMapper工具类实现 2. 核心代码片段 以下代码为spring动态注册接口代码示例 Autowired private RequestMappingHandlerMapping requestMappingHandlerMapping;publ…...

CSS 实现两个圆圈重叠部分颜色不同
这是期望实现的效果,由图可知,圆圈底图透明度是0.4,左侧要求重叠部分透明度是0.7,所以不能通过简单的透明度叠加来实现最右侧的效果。 这就需要另外新建一个图层来叠加在两个圆圈重叠上方。 直接看代码 .circle_hight {width: 1…...

【数据库系统概念】第7-14章集合
文章目录 第七章 数据库设计和E-R模型(重点!!!)~~7.1 设计过程概览(了解)~~7.1.1 设计阶段7.1.2 设计选择 7.2 实体-联系模型(重点掌握)7.2.1 实体集7.2.2 联系集联系集的…...

Kibana
Kibana是一个针对Elastic Search的开源分析及可视化的平台,使用kibana可以查询、查看并与存储在ES索引的数据进行交互操作,可以理解为一个客户端的工具,比如mysql和navicat。 使用kibana能执行高级的数据分析,并能以图表、表格和地…...

C#使用 OpenHardwareMonitor获取CPU或显卡温度、使用率、时钟频率相关方式
C# 去获取电脑相关的基础信息,还是需要借助 外部的库,我这边尝试了自己去实现它 网上有一些信息,但不太完整,都比较零碎,这边尽量将代码完整的去展示出来 OpenHardwareMonitor获取CPU的温度和频率需要管理员权限 在没…...
K8S--- volumesvolumeMount
一、Volume 简介 在容器当中的磁盘文件(on-disk file )是短暂的(ephemeral),这会对重要的应用程序或者数据产生一些问题。当容器崩溃或停止时,会出现一个问题,即容器状态不会被保存,因此在容器生命周期内被创建或者修改的文件都将丢失。在容器崩溃期间,kubelet会以干净状…...

AntV-G6 -- 将G6图表应用到项目中
1. 效果图 2. 安装依赖 npm install --save antv/g6 3. 代码 import { useEffect } from alipay/bigfish/react; import G6 from antv/g6;const data {id: root,label: 利息收入,subLabel: 3,283.456,ratio: 3,children: [{id: child-a,label: 平均利息,subLabel: 9%,ratio:…...
第二百五十回
文章目录 1. 概念介绍2. 使用方法2.1 简单用法2.2 自定义用法 3. 示例代码4. 内容总结 我们在上一章回中介绍了"三方包open_settings"相关的内容,本章回中将介绍另外一个三方包:bluetooth_enable_fork.闲话休提,让我们一起Talk Flu…...

如何把硬盘(分区)一分为二?重装系统的小伙伴不可不看
注意事项:本教程操作不当会导致数据丢失 请谨慎操作 请谨慎操作 请谨慎操作 前言 相信各位小伙伴都会切土豆吧,本教程就是教大家如何切土豆切得好的教程。 啊哈哈哈,开玩笑的。 比如你有一个D盘是200GB,想要把它变成两个100G…...

【AI视野·今日NLP 自然语言处理论文速览 第六十六期】Tue, 31 Oct 2023
AI视野今日CS.NLP 自然语言处理论文速览 Tue, 31 Oct 2023 (showing first 100 of 141 entries) Totally 100 papers 👉上期速览✈更多精彩请移步主页 Daily Computation and Language Papers The Eval4NLP 2023 Shared Task on Prompting Large Language Models a…...

解决Canvas画图清晰度问题
最近在开发Web端远程桌面的时候遇到的一个问题,解决记录一下,分享给各位有需要用到的朋友。 先吹下水:远程桌面的连接我们是通过Websocket连接后,后端不断返回远程端的界面二进制数据流,我接收到之后转为图像…...

zookeeper经典应用场景之分布式锁
1. 什么是分布式锁 在单体的应用开发场景中涉及并发同步的时候,大家往往采用Synchronized(同步)或者其他同一个JVM内Lock机制来解决多线程间的同步问题。在分布式集群工作的开发场景中,就需要一种更加高级的锁机制来处理跨机器的进…...

红队专题-Web安全/渗透测试-文件上传/下载/包含
文件上传/下载/包含 招募六边形战士队员利用目录穿越反弹SHELL实战测试2.2 提交报文修改检测3.2 文件内容检测绕过完整文件结构 检测 第四章:解析漏洞第一节 常见解析漏洞iis/nginx php fastcgi 取值错误 解析漏洞 (配置错误)nginx 文件名逻…...

安装阿里云CLI之配置阿里云凭证信息
有时候需要再主机上通过 OpenAPI 的调用访问阿里云,并完成控制,此时就需要在服务器上安装阿里云CLI,并完成账号的设置。 1. 登录阿里云创建账号 1.1 点击阿里云头像 ——》 控制访问 ——》创建一个拥有DNS权限的用户 这个用户不用太多权限…...
阿里云和腾讯云2核2G3M服务器上传速度多少?
2核2G3M服务器上传速度多少?上传是按10M带宽算,上传速度是1280KB/秒,即1.25M/秒;下载速度按3M带宽计算,下载速度是384KB/秒。本文阿腾云atengyun.com是以阿里云为例的,阿里云服务器当公网带宽小于10M及10M以…...

Python中的cls语法
在Python中,cls 是一个用于指代类本身的约定性名称,通常用作类方法(class method)中的第一个参数。cls 类似于 self,它是对类的引用,而不是对实例的引用。cls 通常在类方法中用于访问类级别的属性和方法。举…...
【Java】java -jar 读取jar包之外的yml
需求描述 springboot项目接入nacos配置,代码中使用bootstrap.yml来指定nacos信息,为了防止不同环境的来回切换,服务器中都单独在放一个bootstrap.yml,来指定具体环境的nacos配置,如sit服务器使用sit的nacos配置&#…...

遥感影像-语义分割数据集:山体滑坡数据集详细介绍及训练样本处理流程
原始数据集详情 简介:该遥感滑坡数据集由卫星光学图像、滑坡边界的形状文件和数字高程模型组成。该数据集中的所有图像,即770张滑坡图像(红点)和2003张非滑坡图像,都是从2018年5月至8月拍摄的TripleSat卫星图像中截取…...
ubuntu 22.04 安装r-base时缺少r-recommended
sudo apt-get install r-base时报错: 下列软件包有未满足的依赖关系: r-base : 依赖: r-recommended ( 4.3.2-1.2004.0) 但无法安装它 E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。 解决方…...

HarmonOS 通用组件(Button)
本文 我们来看看基础组件中的 Button 这是 ArkTS ui 原生支持的一个组件 用来创建不同样式的按钮 首先 我们还是创建一个最基本的组件结构 Entry Component struct Index {build() {Row() {Column() {}.width(100%)}.height(100%)} }我们可以在 Column 组件中 加入一个button…...

idea大量爆红问题解决
问题描述 在学习和工作中,idea是程序员不可缺少的一个工具,但是突然在有些时候就会出现大量爆红的问题,发现无法跳转,无论是关机重启或者是替换root都无法解决 就是如上所展示的问题,但是程序依然可以启动。 问题解决…...
SkyWalking 10.2.0 SWCK 配置过程
SkyWalking 10.2.0 & SWCK 配置过程 skywalking oap-server & ui 使用Docker安装在K8S集群以外,K8S集群中的微服务使用initContainer按命名空间将skywalking-java-agent注入到业务容器中。 SWCK有整套的解决方案,全安装在K8S群集中。 具体可参…...

基于ASP.NET+ SQL Server实现(Web)医院信息管理系统
医院信息管理系统 1. 课程设计内容 在 visual studio 2017 平台上,开发一个“医院信息管理系统”Web 程序。 2. 课程设计目的 综合运用 c#.net 知识,在 vs 2017 平台上,进行 ASP.NET 应用程序和简易网站的开发;初步熟悉开发一…...
java 实现excel文件转pdf | 无水印 | 无限制
文章目录 目录 文章目录 前言 1.项目远程仓库配置 2.pom文件引入相关依赖 3.代码破解 二、Excel转PDF 1.代码实现 2.Aspose.License.xml 授权文件 总结 前言 java处理excel转pdf一直没找到什么好用的免费jar包工具,自己手写的难度,恐怕高级程序员花费一年的事件,也…...

聊聊 Pulsar:Producer 源码解析
一、前言 Apache Pulsar 是一个企业级的开源分布式消息传递平台,以其高性能、可扩展性和存储计算分离架构在消息队列和流处理领域独树一帜。在 Pulsar 的核心架构中,Producer(生产者) 是连接客户端应用与消息队列的第一步。生产者…...

零基础设计模式——行为型模式 - 责任链模式
第四部分:行为型模式 - 责任链模式 (Chain of Responsibility Pattern) 欢迎来到行为型模式的学习!行为型模式关注对象之间的职责分配、算法封装和对象间的交互。我们将学习的第一个行为型模式是责任链模式。 核心思想:使多个对象都有机会处…...

Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决
Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决 问题背景 在一个基于 Spring Cloud Gateway WebFlux 构建的微服务项目中,新增了一个本地验证码接口 /code,使用函数式路由(RouterFunction)和 Hutool 的 Circle…...
2023赣州旅游投资集团
单选题 1.“不登高山,不知天之高也;不临深溪,不知地之厚也。”这句话说明_____。 A、人的意识具有创造性 B、人的认识是独立于实践之外的 C、实践在认识过程中具有决定作用 D、人的一切知识都是从直接经验中获得的 参考答案: C 本题解…...

AI,如何重构理解、匹配与决策?
AI 时代,我们如何理解消费? 作者|王彬 封面|Unplash 人们通过信息理解世界。 曾几何时,PC 与移动互联网重塑了人们的购物路径:信息变得唾手可得,商品决策变得高度依赖内容。 但 AI 时代的来…...

2025季度云服务器排行榜
在全球云服务器市场,各厂商的排名和地位并非一成不变,而是由其独特的优势、战略布局和市场适应性共同决定的。以下是根据2025年市场趋势,对主要云服务器厂商在排行榜中占据重要位置的原因和优势进行深度分析: 一、全球“三巨头”…...