mirror of
https://github.com/Estom/notes.git
synced 2026-04-24 10:34:11 +08:00
spring 完结
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.ykl.shangguigu08;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Shangguigu08Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Shangguigu08Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Alipay.com Inc.
|
||||
* Copyright (c) 2004-2022 All Rights Reserved.
|
||||
*/
|
||||
package com.ykl.shangguigu08.reactor;
|
||||
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* @author yinkanglong
|
||||
* @version : ObserverDemo, v 0.1 2022-10-12 19:47 yinkanglong Exp $
|
||||
*/
|
||||
public class ObserverDemo extends Observable {
|
||||
|
||||
/**
|
||||
* 通过Java8中的类实现响应式编程。
|
||||
* 简单来说,就是观察值模式。
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
ObserverDemo observerDemo = new ObserverDemo();
|
||||
|
||||
observerDemo.addObserver((o,arg)->{
|
||||
System.out.println("发生变化");
|
||||
});
|
||||
|
||||
observerDemo.addObserver((o,arg)->{
|
||||
System.out.println("准备改变");
|
||||
});
|
||||
|
||||
observerDemo.setChanged();
|
||||
observerDemo.notifyObservers();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Alipay.com Inc.
|
||||
* Copyright (c) 2004-2022 All Rights Reserved.
|
||||
*/
|
||||
package com.ykl.shangguigu08.reactor;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author yinkanglong
|
||||
* @version : TestReactor, v 0.1 2022-10-13 10:25 yinkanglong Exp $
|
||||
*/
|
||||
public class TestReactor {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//reactor中的核心语法
|
||||
Flux.just(1,2,3,4).subscribe(System.out::print);
|
||||
Mono.just(1).subscribe(System.out::print);
|
||||
|
||||
//其他方法
|
||||
// Integer[] array = {1,2,3,4};
|
||||
// Flux.fromArray(array);
|
||||
//
|
||||
// List<Integer> list = Arrays.asList(array);
|
||||
// Flux.fromIterable(list);
|
||||
//
|
||||
// Stream<Integer> stream = list.stream();
|
||||
// Flux.fromStream(stream);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ykl.shangguigu08;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class Shangguigu08ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user