自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

weixin_43978420的博客

技术类博客

  • 博客(88)
  • 资源 (2)
  • 收藏
  • 关注

原创 spring aop自定义注解,获取注解上的值

注解@Target({ElementType.METHOD, ElementType.TYPE})@Retention(RetentionPolicy.RUNTIME)@Documentedpublic @interface XXXCache{ long timeout() default 10 * 60 * 1000L; String deadline() default "";}通知@Around(value = "@annotation(com.xxx.xxx.ann

2022-05-19 11:39:57 1416

原创 spring启动部分方法

这里有两个入口:,一个是org.springframework.context.support.AbstractApplicationContext#invokeBeanFactoryPostProcessors 实例化之前的操作;一个是org.springframework.context.support.AbstractApplicationContext#finishBeanFactoryInitialization 实例化和初始化操作。...

2022-05-16 16:00:14 178

原创 java 中jdk动态代理和CGLIB动态代理

java 中jdk动态代理动态代理实践过程定义接口定义接口实现类定义代理类行为(类似于spring中aop的各种通知)代理测试打印结果jdk的动态代理是需要目标接口的,而spring提供的cglib代理是不需要目标接口的。动态代理实践过程定义接口public interface Person { public void rentHouse(); public void rentHouse(String name);}定义接口实现类public class Renter imp

2022-05-12 15:59:36 482 1

原创 spring的bean生命周期

spring的bean生命周期bean实例化阶段1、 BeanFactoryPostProcessor接口的postProcessBeanFactory方法2、 BeanNameAware接口3、BeanFactoryAware/ApplicationContextAware接口bean初始化阶段4、BeanPostProcessor接口两个方法5、 执行BeanPostProcessor的postProcessBeforeInitialization方法6、InitializingBean接口的after

2022-05-12 10:59:26 351 1

原创 spring中事件发布,监听处理

spring中事件发布,监听处理事件发布(事件发布者)事件定义事件监听使用事件发布(事件发布者)事件发布是一个service,需要实现ApplicationEventPublisherAware接口,代码示例:@Servicepublic class UserRegisterService implements ApplicationEventPublisherAware { private ApplicationEventPublisher applicationEventPublish

2022-05-10 10:10:54 271

原创 java多线程常见工具类使用

java多线程场景工具类使用CountDownLatch使用CyclicBarrier使用Exchanger使用Semaphore信号量Condition交替打印123,共10次线程main、线程0、线程1按照顺序依次执行线程池内部线程执行任务报错处理execute提交的任务(无返回值)submit提交的任务报错CountDownLatch使用import java.util.concurrent.CountDownLatch;import java.util.concurrent.ExecutorS

2022-05-05 14:12:27 2188

原创 设计模式的记录

工厂模式使用场景:对象的创建 和 对象的使用 分离建造者模式使用场景:产品的创建需要固定的步骤,适合产品族类的场景,比如产品a,产品b通产品系单例模式使用场景:独一份资源使用静态内部类方式构建,线程安全public class Singleton1 { private Singleton1() {} private static final Singleton1 single = new Singleton1(); //静态工厂方法 public static

2022-04-22 12:03:27 261

原创 sql批量插入,遇到重复更新

@Insert("<script>" + "insert into `test_table` " +" (`biz_type`, `region_id`, `az_id`, `ecs_category_3`, `ecs_category_3_en`, " +" `is_close_limit`,`cycle_available_count`,`cycle_sale_rate`,`cycle_turnaround_days`,

2022-04-13 10:29:03 576

原创 java反射的简单实践

package wang.study.reflect;import lombok.Data;import java.lang.reflect.Constructor;import java.lang.reflect.Field;import java.lang.reflect.Method;@Datapublic class User { private String name; private String passwd; private Integer a

2022-04-06 15:11:55 204

原创 查看mysql表结构

SELECT COLUMN_NAME, COLUMN_TYPE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA ='database' AND TABLE_NAME = 'table'

2022-04-06 11:54:46 717

原创 ClassLoader类学习

自定义类加载器如果要打破双亲委派模型,就继承ClassLoader类,重写loadclass方法;如果不想打破双亲委派模型,就继承ClassLoader类,重写findclass方法。

2022-04-06 11:19:37 195

原创 sql优化神器 explain

查看执行计划:EXPLAIN SELECT * FROM xxx WHERE id=12|id|select_type|table|partitions|type|possible_keys|key|key_len|ref|rows|filtered|Extra|id:查询序列号select_type:普通查询、联合、子查询table:查询表type:显示的是访问类型,是较为重要的一个指标,结果值从好到坏依次是:system > const > eq_ref > ref &gt

2022-03-29 13:53:00 724

原创 jdk自带的工具和运维

jdk自带工具1 jstack命令,查询进程中线程的信息2 jps命令,查看java进程id3 jmap命令,查看堆信息4 jstat命令,查看内存jvm内存结构方法区、虚拟机栈、本地方法栈、程序计数器、堆区java8中hotspot虚拟机对方法区的实现是用元空间:元空间并不在虚拟机中,而是使用本地内存,字符串常量池移到堆区堆区又可以划分为:新生代(伊甸区,from,to)、老年代...

2022-03-26 20:59:54 1588

原创 给定一个二叉树,BFS遍历

public static Queue<Integer> bfs(TreeNode root){ Queue<Integer> queue=new LinkedList<>(); Queue<TreeNode> help=new LinkedList<>(); help.offer(root); while (!help.isEmpty()){ TreeNod.

2022-03-20 10:20:36 560

原创 给定一个数组,返回对应的链表存储

public static ListNode buildLinks(int[] arr) { ListNode head = null; for (int e : arr) { head = buildLink(head, e); } return head; } public static ListNode buildLink(ListNode head, int v) { if (hea.

2022-03-20 09:59:27 458

原创 给定一个数组,返回对应的二叉树结构

例如:给定数组[1,2,2,3,4,4,3]返回为:代码如下:public static TreeNode buildTree(Integer[] arr){ if(arr.length==1) return new TreeNode(arr[0]); Queue<TreeNode> queue=new LinkedList<>(); TreeNode root=new TreeNode(arr[0]); que

2022-03-20 09:56:21 174

原创 力扣,两两交换链表中的节点

class Solution { public static ListNode swapPairs(ListNode head) { if(head==null||head.next==null) return head; ListNode result=null; ListNode index=head; // 记录链表的交换前的前置节点位置 ListNode pre=null; while (ind.

2022-03-19 20:50:15 143

原创 力扣,删除链表中第N个节点

题目如下:这里提供两种思路,大同小异思路一:统计链表长度,记录链表尾,根据总长和倒数N的位置计算删除节点之前的位置,删除返回class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { // 链表总长 int len=0; // 链表尾巴 ListNode tail=null; ListNode tem=head;

2022-03-19 17:37:37 470

原创 三数之和的思路

给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有和为 0 且不重复的三元组。注意:答案中不可以包含重复的三元组。来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/3sum著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。解题思路// 要用双指针,先排序// 固定最小的数// 然后指针从两头移动,判断之和等于0存储...

2022-03-15 11:15:05 160

原创 字符串判断是否子串

public static boolean isSub(String s,String tar){ int i = 0,j = 0; while (i<s.length()&&j<tar.length()){ if(s.charAt(i) == tar.charAt(j)){ j++; } i++; } if(j

2022-03-02 12:02:45 601

原创 树的先序、中序、后序遍历

static public class TreeNode { int val; TreeNode left; TreeNode right; TreeNode() {} TreeNode(int val) { this.val = val; } TreeNode(int val, TreeNode left, TreeNode right) { this.val

2022-03-02 11:09:24 85

原创 力扣1 求和

给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。你可以按任意顺序返回答案。public static int[] twoSum2(int[] nums, int target) { int[] indexs = new int[2]; HashMap<Integer,Integer&gt

2022-02-25 16:54:13 59

原创 netty Slice 零拷贝 和 CompositeByteBuf

@Slf4jpublic class TestSlice { public static void main(String[] args) { ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(10); byteBuf.writeBytes(new byte[]{'a','b','c','d','e','f','g','h','i','j'}); byte[] bytes = new byte[10]

2022-02-16 11:13:34 368

原创 netty NioEventLoop

@Slf4jpublic class TestEventLoop { public static void main(String[] args) { NioEventLoopGroup group = new NioEventLoopGroup(2); // io 事件 普通任务 定时任务// DefaultEventLoopGroup eventExecutors = new DefaultEventLoopGroup(); // 普通任务 定时任务

2022-02-16 10:36:00 54

原创 netty closeFuture

@Slf4jpublic class CloseFutureClient3 { public static void main(String[] args) throws InterruptedException { // future和promise 的类型都是和异步方法配套使用,用来处理结果 NioEventLoopGroup group = new NioEventLoopGroup(); ChannelFuture channelFutur

2022-02-16 10:34:28 342

原创 netty ChannelFuture

@Slf4jpublic class HelloClient { public static void main(String[] args) throws InterruptedException { // future和promise 的类型都是和异步方法配套使用,用来处理结果 ChannelFuture channelFuture = new Bootstrap() .group(new NioEventLoopGroup())

2022-02-16 10:32:58 181

原创 netty Pipeline

@Slf4jpublic class TestPipeline { public static void main(String[] args) { new ServerBootstrap() .group(new NioEventLoopGroup()) .channel(NioServerSocketChannel.class) .childHandler(new ChannelIn

2022-02-16 10:31:15 1284

原创 netty Future和Promise

nettyFuture@Slf4jpublic class TestNettyFuture { public static void main(String[] args) throws ExecutionException, InterruptedException { // 当作线程池 NioEventLoop单个线程 NioEventLoopGroup group = new NioEventLoopGroup(); EventLoop e

2022-02-16 10:29:41 179

原创 nettyByteBuf

/** * 容量可以动态扩容 */public class TestByteBuf { public static void main(String[] args) { ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(); StringBuilder sb = new StringBuilder(); System.out.println(buf); for(int i=0;i<

2022-02-16 10:28:07 109

原创 netty服务器和客户端

服务器public class HelloServer { public static void main(String[] args) { // 1 启动器负责组装netty组件,启动服务器 new ServerBootstrap() // 2 group组 线程和选择器 .group(new NioEventLoopGroup()) // 选择实现 nio oio bi

2022-02-15 10:55:14 1259

原创 匈牙利命名和驼峰命名相互转换java

// 大小写ASCII码固定差距 static int gap = 'a'-'A'; public static void main(String[] args) { String str = "person_first_name"; String result = parseStrToCammeCase(str); System.out.println(result); System.out.println(parseCa

2022-02-14 10:34:20 259

原创 异步IO的简单理解

BIO NIO AIOAIO用来解决数据复制阶段的阻塞问题,异步IO不再作为重点io_uring

2022-02-11 14:31:08 716

原创 IO模型的5中模式

辨析阻塞IO非阻塞IO多路复用信号驱动异步IO参考:unix网络编程前言:在LInux系统下,用户空间会和内核空间可以互相切换阻塞IO阻塞IO:由用户空间切换成内核空间,内核空间在等待数据到达,数据到达后从网卡复制到内存,复制结束由内核空间切换成用户空间,读取。在此过程中用户线程一直被阻塞。(处理一个事件不能处理其他事件)同步阻塞非阻塞IO非阻塞IO:等待数据不阻塞,数据到达复制阶段也阻塞。同步非阻塞多路复用selector,先阻塞住,有事件过来才不阻塞;read也阻塞。节省了等等事件

2022-02-11 14:09:57 763 1

原创 nio服务多线程版本

public static void main(String[] args) throws IOException { Thread.currentThread().setName("boss"); ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.configureBlocking(false); Selector boss = Selector.open();

2022-02-11 11:40:08 255

原创 nio使用可写事件处理一次性写不完情况

服务端 public static void main(String[] args) throws IOException { ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.configureBlocking(false); Selector selector = Selector.open(); ssc.register(selector, SelectionKey.O

2022-02-10 18:38:50 326

原创 nio编程service

public static void main(String[] args) throws IOException { // 创建select Selector selector = Selector.open(); ServerSocketChannel ssc = ServerSocketChannel.open(); ssc.configureBlocking(false); // 注册 select和channel联.

2022-02-10 18:04:11 308

原创 nio文件和文件夹操作例子

统计一个文件夹下特定文件的数目public static void main(String[] args) throws IOException { // 统计文件夹出现的数目 AtomicInteger dirCount = new AtomicInteger(); // 统计文件出现的数目 AtomicInteger fileCount = new AtomicInteger(); Files.walkFileTree(Paths.

2022-02-10 14:12:14 278

原创 netty学习

nio三大组件channelBuffercapacity 表示buffer能装的最大数据position 代表当前读写指针indexlimit 读写限制写模式:position写的位置;limit写的限制读模式:position度的位置;limit读的限制flip 切换读模式clear 切换写模式compact 压缩 读模式下,没有读完,需要写的时候调用selector...

2022-02-10 10:11:49 381

原创 接口幂等性设计

新增、更新操作会有幂等性问题,幂等性指的是多次操作,服务返回结果相同。支付场景中支付系统在被调用时需要满足幂等性1.采用业务逻辑判断保证接口幂等2.采用全局token方式判断

2022-02-07 10:29:16 288

原创 shell学习

shell学习输出hello world运行shell有两种方法输出hello world// 指定用/bin/bash下的解释器来执行#!/bin/bashecho "Hello World !"运行shell有两种方法1、作为可执行程序chmod +x ./test.sh #使脚本具有执行权限./test.sh #执行脚本2、作为解释器参数// 选用/bin/sh下的解释器执行 test.sh文件/bin/sh test.sh...

2021-12-16 10:02:44 1485

zookeeper-01.xmind

zook学习笔记

2021-02-06

zookeeper-01.xmind

zk学习笔记

2021-02-06

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除