java 与 springboot
package geektime.spring.springbucks;
import geektime.spring.springbucks.model.Coffee;
import geektime.spring.springbucks.model.CoffeeOrder;
import geektime.spring.springbucks.model.OrderState;
import geektime.spring.springbucks.service.CoffeeService;
import geektime.spring.springbucks.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Date;
@Component
@Slf4j
public class SpringbucksRunner implements ApplicationRunner {
@Autowired
private CoffeeService coffeeService;
@Autowired
private OrderService orderService;
@Override
public void run(ApplicationArguments args) throws Exception {
coffeeService.initCache()
.then(
coffeeService.findOneCoffee("mocha")
.flatMap(c -> {
CoffeeOrder order = createOrder("Li Lei", c);
return orderService.create(order);
})
.doOnError(t -> log.error("error", t)))
.subscribe(o -> log.info("Create Order: {}", o));
log.info("After Subscribe");
Thread.sleep(5000);
}
private CoffeeOrder createOrder(String customer, Coffee... coffee) {
return CoffeeOrder.builder()
.customer(customer)
.items(Arrays.asList(coffee))
.state(OrderState.INIT)
.createTime(new Date())
.updateTime(new Date())
.build();
}
}
本文由博客群发一文多发等运营工具平台 OpenWrite 发布
java 与 springboot的更多相关文章
- Java结合SpringBoot拦截器实现简单的登录认证模块
Java结合SpringBoot拦截器实现简单的登录认证模块 之前在做项目时需要实现一个简单的登录认证的功能,就寻思着使用Spring Boot的拦截器来实现,在此记录一下我的整个实现过程,源码见文章 ...
- Java逆向工程SpringBoot + Mybatis Generator + MySQL
Java逆向工程SpringBoot+ Mybatis Generator + MySQL Meven pop.xml文件添加引用: <dependency> <groupId> ...
- JAVA - 创建SpringBoot项目
JAVA - 创建SpringBoot项目 Spring Boot是由Pivotal团队提供的全新框架,设计目的是用来简化新Spring应用的初始搭建以及开发过程.它主要推崇的是'消灭配置’,实现零配 ...
- Java之SpringBoot自定义配置与整合Druid
Java之SpringBoot自定义配置与整合Druid SpringBoot配置文件 优先级 前面SpringBoot基础有提到,关于SpringBoot配置文件可以是properties或者是ya ...
- Java发送邮件 —— SpringBoot集成Java Mail
用途:此文仅供,自己今后的小程序通过邮件,批量通知用户. 简单记录了一些发送基本邮件的操作. 项目(SpringBoot版本为2.1.2.RELEASE): 核心依赖(其他相关依赖,在其使用的地方具体 ...
- 【Java】SpringBoot入门学习及基本使用
SpringBoot入门及基本使用 SpringBoot的介绍我就不多说了,核心的就是"约定大于配置",接下来直接上干货吧! 本文的实例: github-LPCloud,欢迎sta ...
- 转 Java jar (SpringBoot Jar)转为win可执行的exe程序
原文链接:http://voidm.com/2018/12/29/java-jar-transform-exe/打包Jar工程 将java项目打包成jar工程,可以是文章以SpringBoot为例po ...
- vs code 搭建java maven springboot环境
Java Extension Pack,Maven for Java,Spring Boot Extension Pack https://blog.csdn.net/qq_26026975/arti ...
- 把java(springboot)程序打包docker镜像
前言:要在docker运行java(jar包)程序,就要把程序打包成docker镜像(以下简称镜像),可以先理解为镜像就是jar包 打包需要程序代码,java本身的打包环境(包括jdk和maven), ...
- java事务/springboot事务/redis事务
java事务(数据库事务):jdbc事务--ACID springboot事务:@Transactional--ACID redis事务:命令集合 将redis事务与mysql事务对比: Mysq ...
随机推荐
- .Net微服务实战之负载均衡(上)
系列文章 .Net微服务实战之技术选型篇 .Net微服务实战之技术架构分层篇 .Net微服务实战之DevOps篇 相关源码:https://github.com/SkyChenSky/Sikiro P ...
- Springboot启动扩展点超详细总结,再也不怕面试官问了
1.背景 Spring的核心思想就是容器,当容器refresh的时候,外部看上去风平浪静,其实内部则是一片惊涛骇浪,汪洋一片.Springboot更是封装了Spring,遵循约定大于配置,加上自动装配 ...
- ubuntu DEBIAN_FRONTEND环境变量用法
DEBIAN_FRONTEND环境变量,告知操作系统应该从哪儿获得用户输入.如果设置为"noninteractive",你就可以直接运行命令,而无需向用户请求输入(所有操作都是非交 ...
- Git日常操作指南
git status git add . git commit -m "注释" git stash # 每次 push 前 git pull --rebase // 如果有冲突,解 ...
- web自动化 -- Select(下拉选择框操作)
目标:(现在 select 这种已经很少了.一般都是 ul/li 或者 span/svg) 代码示例:
- three.js 数学方法之Matrix4
今天郭先生说一说three.js中的Matrix4,相较于Matrix3来说,Matrix4和three.js联系的更紧密,因为在4x4矩阵最常用的用法是作为一个变换矩阵.这使得表示三维空间中的一个点 ...
- 深度学习中损失值(loss值)为nan(以tensorflow为例)
我做的是一个识别验证码的深度学习模型,识别的图片如下 验证码图片识别4个数字,数字间是有顺序的,设立标签时设计了四个onehot向量链接起来,成了一个长度为40的向量,然后模型的输入也是40维向量用s ...
- Django学习路
1.脚本不能随便运行,没准 linux 运行完就上不去了 2.pip 在 linux 上 写 pip3 同理 python 写为 python3 3.在 pycharm 上安装库之后,在命令提示符中依 ...
- 7-Pandas之索引调整方法
一.调整索引.修改列标签 1.调整索引的两种情况: 重新索引 设置新的索引 (1)重新索引 在Pandas对象中,其实索引也是一个对象,所以可对其进行修改. 例如:df.index=['a','b', ...
- PHP date_sub() 函数
------------恢复内容开始------------ 实例 从 2013 年 3 月 15 日减去 40 天: <?php$date=date_create("2013-03- ...