springboot启动时执行
发表于|更新于
|浏览量:
人生就象弈棋,一步失误,全盘皆输,这是令人悲哀之事;而且人生还不如弈棋,不可能再来一局,也不能悔棋。——弗洛伊德
springboot在启动时需要执行的代码
可以实现CommandLineRunner接口然后重写run方法,在run方法里执行
1 | package com.ruben.init; |
这样启动后就会输出启动完成了
相关推荐
2022-01-18
子线程中获取request
在这个世界上,一切都预先被谅解了,一切也就被卑鄙地许可了。——《不能承受的生命之轻》 写一个接口,用于测试: 123456789101112131415161718192021222324252627import cn.hutool.core.thread.AsyncUtil;import javax.annotation.Resource;import org.springframework.web.bind.annotation.*;import javax.servlet.http.HttpServletRequest;import java.util.concurrent.CompletableFuture;@RestController@RequestMapping("test")public class TestController { @Resource private HttpServletRequest request; @GetMapping("request") public String ...
2023-10-30
r2dbc事务处理
劳动创造了人本身。——恩格斯 官方demo: https://github.com/spring-projects/spring-data-examples/blob/main/r2dbc/example/src/main/java/example/springdata/r2dbc/basics/TransactionalService.java 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152/* * Copyright 2019-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy...
2022-10-06
编写mybatis脱敏插件
错误是不可避免的,但是不要重复错误——周恩来 首先贴成品链接:https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/275 使用方式: 在你的vo或者po/do上添加注解@Desensitization可指定预设类型type为:cn.hutool.core.util.DesensitizedUtil.DesensitizedType例如 12@Desensitization(type = DesensitizedUtil.DesensitizedType.EMAIL)private String email; 也可自定义正则表达式 12@Desensitization(regex = "(?<=\\d{3})\\d(?=\\d{4})")private String mobile; 还可以自定义处理器进行处理 12@Desensitization(handler = MyDesensitizedHandler.class)private String myFie...
2023-06-01
下载文件url为MultipartFile
良好的秩序是一切的基础。——伯克 代码如下: 123456789101112131415161718192021222324252627282930313233343536373839404142import lombok.Cleanup;import lombok.SneakyThrows;import lombok.val;import org.apache.commons.fileupload.FileItem;import org.apache.commons.fileupload.FileItemFactory;import org.apache.commons.fileupload.disk.DiskFileItemFactory;import org.dromara.hutool.core.io.IoUtil;import org.dromara.hutool.core.net.url.URLUtil;import org.springframework.http.MediaType;import org.springframework.web.multipar...
2023-09-01
apache-streamparkpr和代码规范指南
世界上本来就有许多格格不入的事物为了共存而不得不相互接受。——博尔赫斯《沙之书》 最近在为streampark起草代码规范指南,对应的pr如下 https://github.com/apache/incubator-streampark-website/pull/226 对应的内容: 12345678910111213141516<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); yo...
2021-04-08
mp数据源加密
不宝金玉,而忠信以为宝。——《礼记》 在开发中,我们难免可能会担心数据库账号密码泄露 我们可以使用mybatis-plus自带的数据安全保护进行加密 123456789101112public static void main(String[] args) throws Throwable { // 生成 16 位随机 AES 密钥 String randomKey = AES.generateRandomKey(); // 随机密钥加密 String url = AES.encrypt("jdbc:mysql://localhost:3306/ruben?autoReconnect=true&zeroDateTimeBehavior=CONVERT_TO_NULL&useUnicode=true&characterEncoding=utf-8&useSSL=false&nullCatalogMeansCurrent=true&serverTimezone=Asia/Shanghai&...
