Spring Bean加载的三种方式

2024年4月14日 没有评论

1.通过XML配置文件

package com.angu.bean.xml;
import lombok.Data;
@Data
public class XmlPerson {
    private String name;
    private String address;
    private Integer age;
}

通过bean标签配置XmlPerson类

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/bean[......]

继续阅读。。。

Java8通过Stream将List转换成Map类型

2024年4月12日 没有评论
  1. Java提供的api接口
    public static <T, K, U>
    Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper,
                                    Function<? super T, ? extends U> valueMapper) {
        return toMap(keyMapper, valueMapper, throwingMerger(),[......]

继续阅读。。。

分类: Java 标签: , ,

通过一条SQL真正理解 JoinPoint和PointCut

2024年4月6日 没有评论
update emp t set t.salary = 100 where dep_id = 100
  1. emp 就是java中的一个类。
  2. emp表的中数据可以看作是类中的方法,如果emp有10条数据,就代表这个类有10个方法。

  3. 每条数据都是JoinPoint,对应Java类中的每个方法都是一个JoinPoint。

  4. dep_id = 100是一个查询条件,它是用来查询出自己感兴趣的数据,PointCut本质也是一个条件,用来筛选出自己感兴趣的方法。

    @Service
    @Aspect
    public class AccountLog {
    @Pointcut("execution(* com.x[......]

继续阅读。。。

分类: Spring Framework 标签:

使用CompletableFuture实现滴滴打车

需求背景

打车回家,同时叫多辆网约车,相应最快的网约车可以抢到订单,其他网约车抢单是失败。

数据准备

数据类

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Car  {
    /**
     * 网约车名字
     */
    private String name;
    /**
     * 网约车相应时间
     */
    private Integer responseTime;
}    

模拟数据

public class CarData {
    /**
     * 模拟一些[......]

继续阅读。。。

分类: Java 标签: ,

创建带序列的表列

2021年1月16日 没有评论

要求数据库版本12c及以上

语法

GENERATED (ALWAYS | (BY DEFAULT [ON NULL])) AS IDENTITY
[sequence_options,...]

语法解析

语法
语法说明

GENERATED ALWAYS AS IDENTITY
该列永远使用序列产生的值

GENERATED BY DEFAULT AS IDENTITY
该类未赋值时使用序列产生的值

GENERATED BY DEFAULT ON NULL AS IDENTITY
该类为空时使用序列产生的值

举个[......]

继续阅读。。。