以前用springmvc时,程序初始化资源用@PostConstruct注解和ApplicationContextAware接口。
springboot提供了一个新接口可以实现这个功能,就是CommandLineRunner接口。比如程序启动后,进行数据库资源的初始化、redis缓存的初始化等。

拿bean生命周期中的例子加上这个接口测试
https://blog.csdn.net/csj50/article/details/107975473

1、添加BeanLifeCycle.java

package com.example.base;import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;@Component
public class BeanLifeCycle implements BeanNameAware, BeanFactoryAware, ApplicationContextAware, InitializingBean,DisposableBean, SmartLifecycle, BeanPostProcessor, CommandLineRunner {private boolean isRunning = false;@Overridepublic void setBeanName(String name) {System.out.println("========== 执行BeanNameAware接口");}@Overridepublic void setBeanFactory(BeanFactory beanFactory) throws BeansException {System.out.println("========== 执行BeanFactoryAware接口");}@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {System.out.println("========== 执行ApplicationContextAware接口");}@PostConstructpublic void initBean() {System.out.println("========== 执行@PostConstruct注解");}@Overridepublic void afterPropertiesSet() throws Exception {System.out.println("========== 执行InitializingBean接口");}@PreDestroypublic void destroyBean() {System.out.println("========== 执行@PreDestroy注解");}@Overridepublic void destroy() throws Exception {System.out.println("========== 执行DisposableBean接口");}@Overridepublic void start() {System.out.println("========== 执行SmartLifecycle接口start方法");isRunning = true;}@Overridepublic void stop() {System.out.println("========== 执行SmartLifecycle接口stop方法");isRunning = false;}/*** 返回true时start方法会被自动执行,返回false则不会*/@Overridepublic boolean isAutoStartup() {System.out.println("========== 执行SmartLifecycle接口isAutoStartup方法");return true;}/*** 1. 只有该方法返回false时,start方法才会被执行。<br/>* 2. 只有该方法返回true时,stop(Runnable callback)或stop()方法才会被执行。*/@Overridepublic boolean isRunning() {System.out.println("========== 执行SmartLifecycle接口isRunning方法");return isRunning;}/*** 如果工程中有多个实现接口SmartLifecycle的类,则这些类的start的执行顺序按getPhase方法返回值从小到大执行。<br/>* 例如:1比2先执行,-1比0先执行。 stop方法的执行顺序则相反,getPhase返回值较大类的stop方法先被调用,小的后被调用。*/@Overridepublic int getPhase() {return 0;}@Overridepublic void stop(Runnable callback) {System.out.println("========== 执行SmartLifecycle接口stop(Runnable callback)方法");callback.run();isRunning = false;}/*** 实例化Bean之前*/@Overridepublic Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {if ("threadPool".equals(beanName)) {System.out.println("========== 执行postProcessBeforeInitialization方法" + beanName);}return bean;}/*** 实例化Bean之后*/@Overridepublic Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {if ("threadPool".equals(beanName)) {System.out.println("========== 执行postProcessAfterInitialization方法" + beanName);}return bean;}@Overridepublic void run(String... args) throws Exception {System.out.println("========== 执行CommandLineRunner接口run方法");}}

2、执行结果:

2022-01-28 14:01:30.222 [] INFO  [main] com.example.myboot.MybootApplication :Starting MybootApplication on LAPTOP-M5PHBUE5 with PID 76596 (D:\workspace\study\myboot\target\classes started by sjcui in D:\workspace\study\myboot)
2022-01-28 14:01:30.229 [] INFO  [main] com.example.myboot.MybootApplication :The following profiles are active: model1,model2,dev
2022-01-28 14:01:31.189 [] DEBUG [main] org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration :Searching for mappers annotated with @Mapper
2022-01-28 14:01:31.190 [] DEBUG [main] org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration :Using auto-configuration base package 'com.example.myboot'
2022-01-28 14:01:31.256 [] INFO  [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate :Multiple Spring Data modules found, entering strict repository configuration mode!
2022-01-28 14:01:31.261 [] INFO  [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate :Bootstrapping Spring Data repositories in DEFAULT mode.
2022-01-28 14:01:31.289 [] INFO  [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate :Finished Spring Data repository scanning in 7ms. Found 0 repository interfaces.
2022-01-28 14:01:31.432 [] DEBUG [main] org.apache.ibatis.logging.LogFactory :Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.
2022-01-28 14:01:31.434 [] WARN  [main] org.mybatis.spring.mapper.ClassPathMapperScanner :No MyBatis mapper was found in '[com.example.myboot]' package. Please check your configuration.
2022-01-28 14:01:31.650 [] INFO  [main] c.u.j.configuration.EnableEncryptablePropertiesBeanFactoryPostProcessor :Post-processing PropertySource instances
2022-01-28 14:01:31.651 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Skipping PropertySource configurationProperties [class org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource
2022-01-28 14:01:31.652 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Skipping PropertySource servletConfigInitParams [class org.springframework.core.env.PropertySource$StubPropertySource
2022-01-28 14:01:31.652 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Skipping PropertySource servletContextInitParams [class org.springframework.core.env.PropertySource$StubPropertySource
2022-01-28 14:01:31.653 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
2022-01-28 14:01:31.653 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource systemEnvironment [org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor$OriginAwareSystemEnvironmentPropertySource] to EncryptableSystemEnvironmentPropertySourceWrapper
2022-01-28 14:01:31.653 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource random [org.springframework.boot.env.RandomValuePropertySource] to EncryptablePropertySourceWrapper
2022-01-28 14:01:31.653 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource applicationConfig: [classpath:/config/application-dev.yml] [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
2022-01-28 14:01:31.653 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource applicationConfig: [classpath:/config/application-model2.yml] [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
2022-01-28 14:01:31.653 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource applicationConfig: [classpath:/config/application-model1.yml] [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
2022-01-28 14:01:31.653 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource applicationConfig: [classpath:/config/application.properties] [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
2022-01-28 14:01:31.653 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource applicationConfig: [classpath:/config/application.yml] [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
========== 执行BeanNameAware接口
========== 执行BeanFactoryAware接口
========== 执行ApplicationContextAware接口
========== 执行@PostConstruct注解
========== 执行InitializingBean接口
2022-01-28 14:01:31.728 [] INFO  [main] o.s.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker :Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$920009b9] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-01-28 14:01:31.844 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter :Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter
2022-01-28 14:01:31.853 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.resolver.DefaultLazyPropertyResolver :Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver
2022-01-28 14:01:31.855 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.detector.DefaultLazyPropertyDetector :Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector
2022-01-28 14:01:32.325 [] INFO  [main] org.springframework.boot.web.embedded.tomcat.TomcatWebServer :Tomcat initialized with port(s): 8088 (http)
2022-01-28 14:01:32.461 [] INFO  [main] org.springframework.web.context.ContextLoader :Root WebApplicationContext: initialization completed in 2163 ms
2022-01-28 14:01:32.827 [] INFO  [main] org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor :Initializing ExecutorService
MyListener2 init
app startup at 2022-01-28T14:01:32.929
MyListener1 init
app startup at 2022-01-28T14:01:32.929
MyFilter1 init
MyFilter2 init
2022-01-28 14:01:32.955 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.encryptor.DefaultLazyEncryptor :String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initializing Default String Encryptor
2022-01-28 14:01:32.968 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.configuration.StringEncryptorBuilder :Encryptor config not found for property jasypt.encryptor.key-obtention-iterations, using default value: 1000
2022-01-28 14:01:32.968 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.configuration.StringEncryptorBuilder :Encryptor config not found for property jasypt.encryptor.pool-size, using default value: 1
2022-01-28 14:01:32.968 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.configuration.StringEncryptorBuilder :Encryptor config not found for property jasypt.encryptor.provider-name, using default value: null
2022-01-28 14:01:32.968 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.configuration.StringEncryptorBuilder :Encryptor config not found for property jasypt.encryptor.provider-class-name, using default value: null
2022-01-28 14:01:32.968 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.configuration.StringEncryptorBuilder :Encryptor config not found for property jasypt.encryptor.salt-generator-classname, using default value: org.jasypt.salt.RandomSaltGenerator
2022-01-28 14:01:32.970 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.configuration.StringEncryptorBuilder :Encryptor config not found for property jasypt.encryptor.string-output-type, using default value: base64
2022-01-28 14:01:33.403 [] INFO  [main] com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure :Init DruidDataSource
2022-01-28 14:01:33.586 [] INFO  [main] com.alibaba.druid.pool.DruidDataSource :{dataSource-1} inited
2022-01-28 14:01:33.757 [] DEBUG [main] org.mybatis.spring.SqlSessionFactoryBean :Parsed mapper file: 'file [D:\workspace\study\myboot\target\classes\com\create\xml\TblTeacherInfMapper.xml]'
2022-01-28 14:01:33.771 [] DEBUG [Druid-ConnectionPool-Create-196340990] druid.sql.Connection :{conn-10001,procId-2} connected
2022-01-28 14:01:33.831 [] INFO  [main] com.example.service.TaskBlackListCreateService :创建黑名单 启动初始化..........
2022-01-28 14:01:34.008 [] INFO  [main] io.lettuce.core.EpollProvider :Starting without optional epoll library
2022-01-28 14:01:34.009 [] INFO  [main] io.lettuce.core.KqueueProvider :Starting without optional kqueue library
2022-01-28 14:01:50.211 [] INFO  [main] com.example.service.TaskHotProductService :定时器启动......
2022-01-28 14:01:50.213 [] INFO  [main] com.example.service.TaskPVOneCacheService :启动定时器 PV一级缓存消费..........
2022-01-28 14:01:50.214 [] INFO  [main] com.example.service.TaskPVTwoCacheService :启动定时器 PV二级缓存消费..........
2022-01-28 14:01:50.216 [] INFO  [main] com.example.service.TaskPrizeCreateService :生成奖品信息 启动初始化..........
2022-01-28 14:01:50.218 [] INFO  [main] com.example.service.TaskQunRandomCreateService :随机展示QQ群 启动初始化..........
2022-01-28 14:01:50.243 [] INFO  [main] com.example.service.TaskRankingCreateService :生成榜单 启动初始化..........
2022-01-28 14:01:50.245 [] INFO  [main] com.example.service.TaskTTPrizeCreateService :天天抽奖 启动初始化..........
2022-01-28 14:01:50.246 [] INFO  [main] com.example.service.TaskWeiBoDayHourService :热度刷新任务 启动初始化..........
2022-01-28 14:01:50.383 [] INFO  [Thread-4] com.example.service.TaskPVTwoCacheService :弹出pop=null
2022-01-28 14:01:50.667 [] INFO  [Thread-2] com.example.service.TaskHotProductService :刷新缓存完成
2022-01-28 14:01:51.152 [] INFO  [Thread-2] com.example.service.TaskHotProductService :刷新缓存A完成
2022-01-28 14:01:51.569 [] INFO  [Thread-2] com.example.service.TaskHotProductService :刷新缓存B完成
2022-01-28 14:01:51.569 [] INFO  [Thread-2] com.example.service.TaskHotProductService :product定时刷新完成......
2022-01-28 14:01:52.166 [] INFO  [main] springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping :Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2022-01-28 14:01:52.297 [] INFO  [main] org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor :Initializing ExecutorService 'applicationTaskExecutor'
2022-01-28 14:01:52.417 [] WARN  [main] o.s.b.a.t.ThymeleafAutoConfiguration$DefaultTemplateResolverConfiguration :Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2022-01-28 14:01:52.459 [] INFO  [main] tk.mybatis.mapper.autoconfigure.MapperCacheDisabler :Clear tk.mybatis.mapper.util.MsUtil CLASS_CACHE cache.
2022-01-28 14:01:52.459 [] INFO  [main] tk.mybatis.mapper.autoconfigure.MapperCacheDisabler :Clear tk.mybatis.mapper.genid.GenIdUtil CACHE cache.
2022-01-28 14:01:52.460 [] INFO  [main] tk.mybatis.mapper.autoconfigure.MapperCacheDisabler :Clear tk.mybatis.mapper.version.VersionUtil CACHE cache.
2022-01-28 14:01:52.460 [] INFO  [main] tk.mybatis.mapper.autoconfigure.MapperCacheDisabler :Clear EntityHelper entityTableMap cache.
2022-01-28 14:01:52.460 [] DEBUG [main] org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration :Not found configuration for registering mapper bean using @MapperScan, MapperFactoryBean and MapperScannerConfigurer.
========== 执行SmartLifecycle接口isAutoStartup方法
========== 执行SmartLifecycle接口isRunning方法
========== 执行SmartLifecycle接口isAutoStartup方法
========== 执行SmartLifecycle接口start方法
2022-01-28 14:01:52.687 [] INFO  [main] springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper :Context refreshed
2022-01-28 14:01:52.708 [] INFO  [main] springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper :Found 1 custom documentation plugin(s)
2022-01-28 14:01:52.746 [] INFO  [main] springfox.documentation.spring.web.scanners.ApiListingReferenceScanner :Scanning for api listing references
2022-01-28 14:01:52.868 [] INFO  [main] s.documentation.spring.web.readers.operation.CachingOperationNameGenerator :Generating unique operation named: addCartUsingPOST_1
2022-01-28 14:01:52.870 [] INFO  [main] s.documentation.spring.web.readers.operation.CachingOperationNameGenerator :Generating unique operation named: delCartUsingPOST_1
2022-01-28 14:01:52.875 [] INFO  [main] s.documentation.spring.web.readers.operation.CachingOperationNameGenerator :Generating unique operation named: findAllUsingPOST_1
2022-01-28 14:01:52.877 [] INFO  [main] s.documentation.spring.web.readers.operation.CachingOperationNameGenerator :Generating unique operation named: updateCartUsingPOST_1
2022-01-28 14:01:52.971 [] INFO  [main] s.documentation.spring.web.readers.operation.CachingOperationNameGenerator :Generating unique operation named: deleteUsingGET_1
2022-01-28 14:01:52.972 [] INFO  [main] s.documentation.spring.web.readers.operation.CachingOperationNameGenerator :Generating unique operation named: findByIdUsingGET_1
2022-01-28 14:01:52.974 [] INFO  [main] s.documentation.spring.web.readers.operation.CachingOperationNameGenerator :Generating unique operation named: insertUsingGET_1
2022-01-28 14:01:52.975 [] INFO  [main] s.documentation.spring.web.readers.operation.CachingOperationNameGenerator :Generating unique operation named: updateUsingGET_1
2022-01-28 14:01:54.127 [] INFO  [main] org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor :No TaskScheduler/ScheduledExecutorService bean found for scheduled processing
2022-01-28 14:01:54.142 [] INFO  [main] org.springframework.boot.web.embedded.tomcat.TomcatWebServer :Tomcat started on port(s): 8088 (http) with context path ''
2022-01-28 14:01:54.143 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.caching.RefreshScopeRefreshedEventListener :Refreshing cached encryptable property sources on ServletWebServerInitializedEvent
2022-01-28 14:01:54.143 [] INFO  [main] c.u.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource :Property Source systemProperties refreshed
2022-01-28 14:01:54.143 [] INFO  [main] c.u.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource :Property Source systemEnvironment refreshed
2022-01-28 14:01:54.143 [] INFO  [main] c.u.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource :Property Source random refreshed
2022-01-28 14:01:54.143 [] INFO  [main] c.u.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource :Property Source applicationConfig: [classpath:/config/application-dev.yml] refreshed
2022-01-28 14:01:54.144 [] INFO  [main] c.u.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource :Property Source applicationConfig: [classpath:/config/application-model2.yml] refreshed
2022-01-28 14:01:54.144 [] INFO  [main] c.u.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource :Property Source applicationConfig: [classpath:/config/application-model1.yml] refreshed
2022-01-28 14:01:54.144 [] INFO  [main] c.u.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource :Property Source applicationConfig: [classpath:/config/application.properties] refreshed
2022-01-28 14:01:54.144 [] INFO  [main] c.u.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource :Property Source applicationConfig: [classpath:/config/application.yml] refreshed
2022-01-28 14:01:54.144 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource server.ports [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
2022-01-28 14:01:54.144 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Skipping PropertySource configurationProperties [class org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource
2022-01-28 14:01:54.144 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Skipping PropertySource servletConfigInitParams [class org.springframework.core.env.PropertySource$StubPropertySource
2022-01-28 14:01:54.144 [] INFO  [main] com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter :Converting PropertySource servletContextInitParams [org.springframework.web.context.support.ServletContextPropertySource] to EncryptableEnumerablePropertySourceWrapper
2022-01-28 14:01:54.145 [] INFO  [main] com.example.myboot.MybootApplication :Started MybootApplication in 24.436 seconds (JVM running for 24.808)
========== 执行CommandLineRunner接口run方法
2022-01-28 14:01:57.433 [] INFO  [Thread-10] com.example.service.TaskWeiBoDayHourService :天刷新完成..........
2022-01-28 14:01:57.575 [] INFO  [Thread-10] com.example.service.TaskWeiBoDayHourService :周刷新完成..........
2022-01-28 14:01:57.751 [] INFO  [Thread-10] com.example.service.TaskWeiBoDayHourService :月刷新完成..........

可以看到CommandLineRunner接口run方法是在bean实例化和初始化之后执行的

参考资料:
https://blog.csdn.net/lk142500/article/details/90270592

注:最新代码上传至https://github.com/csj50/myboot

springboot项目创建笔记33 之《初始化资源》相关推荐

  1. springboot项目创建笔记29 之《springboot打包优化2—加载logback.xml问题》

    打包优化分离配置文件后,服务器部署时logback.xml加载有问题.问题就是,在ide中需要设置classpath路径,服务器部署需要设置file路径 ide中运行和测试: #配置外部logback ...

  2. Springboot项目启动前执行数据库初始化脚本

    背景:项目里面遇到了要在springboot项目启动前做数据库初始化的需求.总结一下几种方案: 1.使用flywaydb,启动工程的时候同时初始化脚本.集成倒是不难,主要是要解决bean的顺序加载问题 ...

  3. springboot项目创建全局唯一id生成器

    springboot项目创建全局唯一id生成方法,参考 Snowflake算法 yml文件 #app 全局唯一id生成 app:idGenerator:workerId: 1datacenterId: ...

  4. springboot项目创建右键没有run as

    springboot项目创建右键没有run as 解决方案:右键创建项目得pom.xml文件add as maven project即可.

  5. springboot项目创建和启动

    一.创建springboot项目 Spring Initializr: https://start.spring.io/ 通过这个网站创建springboot项目  选择基本依赖,可创建 二.启动项目 ...

  6. SpringBoot项目——创建菜单与游戏页面

    SpringBoot项目--vue 实现游戏页面 回顾: SpringBoot项目--配置git环境与项目创建 文章目录 SpringBoot项目--vue 实现游戏页面 vue 实现前端页面--We ...

  7. SpringBoot—项目启动时几种初始化操作及SpringApplication类详解

    关注微信公众号:CodingTechWork,一起学习进步. 引言   在使用Spring Boot搭建项目时,启动项目工程,经常遇到一些需要启动初始化数据或者资源的需求,比如提前加载某个配置文件内容 ...

  8. Java web项目创建笔记23 之《spring整合xxl-job》

    xxl-job是一款功能强大的分布式任务调度系统. 部署方法按照官网写的说明即可:https://www.xuxueli.com/xxl-job/ 1.下载release版本代码 https://gi ...

  9. Java web项目创建笔记28 之《手写线程池》

    1.原理 线程池核心点----复用机制 1)提前创建好固定的线程一直在运行状态----死循环实现 2)提交的线程任务缓存到一个并发队列集合中,交给正在运行的线程执行 3)正在运行的线程从队列中获取该任 ...

最新文章

  1. 数据服务器 操作系统,服务器如何选择操作系统
  2. Harbor容器仓库的镜像上传
  3. 数据库字段设置为非空默认值
  4. Winform中实现实时颜色拾取器显示RGB和16进制颜色(附代码下载)
  5. robots.txt文件详解
  6. java cxf服务端_webservice概述及cxf在Java开发中应用(二) 简单搭建cxf服务端
  7. 初学者必学教程——JQuery的简介
  8. 使用PrinterJob进行分页打印
  9. 《软件需求工程》 读书笔记之二
  10. 百度 71 个炸天的开源项目!你知道几个?--ECharts UMeditor Ueditor ZRender
  11. 爬虫实战 -- QQ空间自动点赞
  12. AD学习之旅(10)— 导入元器件到PCB文件
  13. 飞鸽传书2011下载(飞鸽传书)
  14. 系统时钟的时钟源选择
  15. 网页上生成一个印章。
  16. ubuntu linux卸载软件命令,ubuntu安装和卸载软件命令
  17. Mysql数据库的安全策略
  18. 老调重弹-ffmpeg解码视频图像
  19. 移动硬盘插在电脑上提示需要将其格式化,我该怎么办?
  20. r语言c()函数格式,R语言基本操作函数

热门文章

  1. 怎样才能精通 Photoshop?
  2. 基于51单片机的酒精检测仪
  3. 矩阵论:子空间的交与和
  4. c语言类似于 n的标识符,C语言快速入门教程(二)
  5. docker的阿里云镜像加速器的使用
  6. [leetcode 44] Wildcard Matching
  7. vuex的各大属性详细讲解
  8. 邮件标题怎么写才好?
  9. ERP出入库进阶操作与子流程--开源软件诞生28
  10. 淘宝客参数spm,就是指通过这个技术跟踪推广的商品订单