How to execute a piece of logic immediately after the Spring Boot application starts

1. Preface I don't know if you've received this requirement, so just execute some logic when the project starts.For example, simple cache preheating, or broadcasting after going online, and so on.If you use the Spring Boot framework, you can do so with its interfaces CommandLineRunner and ApplicationRunner. 2. CommandLineRunner org.springframe ...

Posted on Mon, 01 Jun 2020 22:56:55 -0400 by vjbrantner@purd

How to use double check lock to implement singleton - ImportNew in Java

This paper is composed of ImportNew-freely flowing style of writing Translation from javacodegeeks . Welcome to join Java team . Please refer to the requirements at the end of the article for reprint. Singleton classes are very common in Java developers, but they pose many challenges to junior developers. One of the key challenges they face i ...

Posted on Mon, 01 Jun 2020 10:01:25 -0400 by will_1990

Using lazy delete and timed delete to realize the local storage cache that can expire

Introduction to localStorage Use localStorage to store data for key value pairs in the browser. sessionStorage is often mentioned together with localStorage, which can store the data of key value pairs in the browser. But the difference between them is: the data stored in localStorage can be kept for a long time; when the page session ends (tha ...

Posted on Sun, 31 May 2020 21:56:24 -0400 by systemtek

spring boot custom starter

spring boot uses starter to solve many configuration problems, but how does it solve these problems Here is a simple example to see how starter sets the default configuration 1, Build starter project The project naming specification is: custom name spring boot starter Let's take a look at my last directory structure   1. Modification pom.xml ...

Posted on Sun, 31 May 2020 12:31:13 -0400 by tibberous

type column parsing of explain

1,const Indicates that the execution step returns at most one row of data. const usually appears in the equivalent query of the primary key or unique index, such as the equivalent query of the primary key id of the t table:It can be considered that it is as fast as a rocket to locate a record by comparing the equivalence between the primary key ...

Posted on Sun, 31 May 2020 11:54:35 -0400 by peter_anderson

Alibaba cloud Centos7 deploys Java web [jar/war/virmach+vps + domain name service]

(1) Part 1: basic jar package running (Tomcat does not need to be configured) [http://60.205.183.114:8081/] 1. Configure Alibaba cloud (Esc student server, image Centos7.7) and connect to the terminal remotely. 2. Install and configure the JDK (refer to https://www.jianshu.com/p/093413f2a04f)a) Install the jdk. b) Find the jdk path configurat ...

Posted on Sun, 31 May 2020 11:37:58 -0400 by LuAn

Four ways to read the properties file in SpringBoot

preface Configuration files are often used in project development. The existence of configuration files solves a lot of repeated work. Today, I'll share four ways to get configuration files in spring boot. Note: the first three test configuration files are spring boot default application.properties file ############ ...

Posted on Sun, 31 May 2020 10:24:51 -0400 by maca134

Configure different access ports for multiple applications in tomcat

Configure different access ports for multiple applications in tomcat Open tomcat installation directory and check conf/server.xml <?xml version="1.0" encoding="UTF-8"?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" /> <Listener c ...

Posted on Sun, 31 May 2020 10:02:39 -0400 by LoneTraveler

Java IO character stream

Character stream Java provides some character stream classes to read and write data in character units, which are specially used for processing text files. Character input stream (Reader) java.io.Reader Abstract class is a super class representing all classes used to read character stream, which can read character information into memory. It de ...

Posted on Sun, 31 May 2020 07:00:59 -0400 by Pioden

Java IO character stream

Character stream Java provides some character stream classes to read and write data in character units, which are specially used for processing text files. Character input stream (Reader) java.io.Reader Abstract class is a super class representing all classes used to read character stream, which can read character information into memory. It de ...

Posted on Sun, 31 May 2020 06:54:08 -0400 by adam84