什么情况下需要引入第三方容器组件? 实际上是大部分情况默认的容器组件是够我们使用的,但是当我们需要一些非常特殊的场景时,如:
基于名称的注入:把一个服务按照名称来区分它不同的实现的时候 属性注入:我们的注入方式有FromService的方式、还有构造函数入参的方式,但是在开源社区我们会有很多这种属性注入的方式,也就是说我们可以直接把服务注册到某一个类的属性里面去而不需要定义构造函数 子容器:可以理解成之前讲过的Scope,但实际上我们还可以用第三方的框架来去实现些特殊的子容器 基于动态代理的AOP:当我们需要在服务中注入我们额外的行为的时候,我们可以用动态代理的能力 .NET Core的依赖注入框架的核心扩展点是:IServiceProviderFactory public interface IServiceProviderFactory<TContainerBuilder> 第三方的依赖注入容器都是使用了这个类来作为扩展点,把自己注入到我们整个的框架里面来,也就是说我们在使用这些依赖注入框架的时候,我们不需要关注说:谁家的特性、谁家的接口是什么样子的,我们只需要使用官方核心的定义就可以了,我们不需要直接依赖这些框架;
public interface IMyService{ void ShowCode(); } public class MyService: IMyService{ public void ShowCode(){ Console.WriteLine($MyService.ShowCode:{GetHashCode()}); } } public class MyServiceV2: IMyService{ public MyNameService NameService{get; set;} public void ShowCode(){ Console.WriteLine($MyServiceV2.ShowCode:{GetHashCode()}, NameService是否为空:{NameService == null}); } } public class MyNameService{} 引入Autofac包:
Autofac.Extensions.DependencyInjection Autofac.Extras.DynamicProxy 在 入口文件 中加入: .UseServiceProviderFactory(new AutofacServiceProviderFactory()) 的作用:注册第三方容器的入口
在 Startup.cs 中添加一个 ConfigureContainer方法:
public void ConfigureContainer(ContainerBuilder builder){ // 一般的写法:先注册具体的实现,然后再告诉它我们想把它标记哪个服务的类型,与之前自带注入的写法是相反的 builder.
Given an array of non-negative integers nums, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Your goal is to reach the last index in the minimum number of jumps.
You can assume that you can always reach the last index.
Solution 很容易想到 \(dp[i]\) 表示以 \(i\) 结尾时的最小步数,考虑如何转移: 可以发现正向的 \(dp\) 比较容易:
\[dp[k] = \min(dp[k],dp[j]+1),\text{where } j+nums[j]\geq k \]
Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
解决方法:
1. 2.9.2版本的Swagger需要添加一个google的guava依赖
<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>30.1-jre</version></dependency> 2.把2.6.3版本更换为一个稳定的版本2.5.6。
fmmall的pom.xml:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.6</version> <relativePath/> <!-- lookup parent from repository --> </parent> 更换稳定版本2.5.6后运行成功!
参考资料:https://blog.csdn.net/weixin_52914457/article/details/123017473
选择排序 非稳定版本与稳定版本 排序过程中选择一个比较大(大到小排序)的数,然后把它放到数组中指定的位置;这时候可以直接与数组中指定位置交换数据,但是可能会导致同值的数据的顺序发生改变,这就是所谓的“不稳定”。可以通过下图来理解所谓的“稳定”和“非稳定”。
不稳定排序算法按数字排序时,会打乱原本同值的花色顺序 [[♠7], [♠2], [♠4], [♠5], [♥2], [♥5]] [[♠7], [♠5], [♥5], [♠4], [♥2], [♠2]] 原来 ♠2 在前 ♥2 在后,按数字再排后,他俩的位置变了 稳定排序算法按数字排序时,会保留原本同值的花色顺序,如下所示 ♠2 与 ♥2 的相对位置不变 [[♠7], [♠2], [♠4], [♠5], [♥2], [♥5]] [[♠7], [♠5], [♥5], [♠4], [♠2], [♥2]] 代码示例(C实现) //非稳定版本 void move_selected_unstable_version(int *arr, int i, int m) { if(m != i) //如果选择的这个数已经是在i位置(当前要放置的位置)就不用移动了 { int tmp = arr[m]; arr[m] = arr[i]; arr[i] = tmp; } } // 稳定版本,为了把 arr[m] 移动到 i,需要把中间的所有元素都右移 void move_selected_stable_version(int *arr, int i, int m) { int j, tmp; if(m !
前后端分离开发,后端需要编写接口说明文档,会耗费比较多的时间。
swagger是一个用于生成服务器接口说明的规范性文档,并且能够对接口进行测试的工具。
1.在api子工程的pom中添加依赖 Swagger2、Swagger UI
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>3.0.0</version> </dependency> 2.在api子工程创建一个swagger配置类(Java配置方式) 在api子工程下的 src - main - java - com.qfedu.fmmall 中新建一个config包,在config包中创建一个类SwaggerConfig。 SwaggerConfig.java: package com.qfedu.fmmall.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.service.Contact; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration @EnableSwagger2 public class SwaggerConfig { //1.配置生成的文档信息 //2.配置生成的接口信息 //Docket封装接口文档信息 @Bean public Docket getDocket(){ ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder(); apiInfoBuilder.
1. 参考资料 窗体顶部添加菜单栏: https://www.cnblogs.com/linkyip/p/13728332.html修改窗体顶部属性:https://blog.csdn.net/sabcdefg/article/details/110733215?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&utm_relevant_index=2自动调整窗口:https://blog.csdn.net/u010779194/article/details/10145465?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.pc_relevant_default&utm_relevant_index=1窗口事件:https://blog.csdn.net/weixin_43646126/article/details/114873835?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&utm_relevant_index=2
2. 项目效果图
如何选购一款合适的固态硬盘 区分各种固态硬盘类型接口与协议 六个参数帮你看懂固态硬盘的那些事儿 90后科技说_哔哩哔哩_bilibili
参数1.总线
参数2:物理接口
注意:
1.台式机或笔记本如果有M.2插槽的话,也要看看主板支持什么协议,是否支持NVME协议?
2.买的固态硬盘也可以看看是否支持NVME协议。
读写一个文件对应顺序读写速度。
读写多个文件对应4k随机读写速度。
1.打开终端输入 ssh-keygen -t ed25519 -C
[email protected] 然后按三下回车 可以看到这个路径 打开它 里面就是公共秘钥
把秘钥复制进去
2.输入命令
ssh -T
[email protected] 输入yes 再次输入 ssh -T
[email protected]就完成了
#拉起容器命令 docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS=-Xms512m -Xmx512m -e discovery.type=single-node -e xpack.security.enabled=true elasticsearch:7.17.3 #命令解释 discovery.type 拉起es容器模式 xpack.security.enabled 相当于开启登录认证 ES_JAVA_OPTS 创建时,调整内存的分配 增加9200/9300的端口映射 docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS=-Xms512m -Xmx512m -e discovery.type=single-node -e xpack.security.enabled=true elasticsearch:7.17.3
C++指针的再认识
基本概念:
对*p,&p,p之间的区别
定义指针的时候使用*p这里定义之后p就是一个指针
由于指针中存放的是地址,需要取地址符号来进行传递
定义指针和使用指针的时候表示是有区别的
如果想获取指针存放地址中对应的值需要使用*p
举例如下:
#include<iostream> using namespace std; int main(){ int a = 10; int *p; // 定义指针变量 p = &a; printf(a变量的地址:%p \n, p); cout<<*p<<endl; return 0; } 输出结果如下:
a变量的地址:000000000061fe14 10
指针函数
int* f(int x,int y);括号的优先级较大,返回的指针
举例:
函数指针
int (*f)(int x, int y),首先f是一个指针,指针指向的是一个函数,