# Springboot
## 介绍
springboot的一些学习练手例子,整合es,mq,quartz,mongodb,kafka,zookeeper,线程池,clieckhouse,gateway,nacos,neo4j,jetty等等等
## 软件架构
springboot
## 分支&模块说明
### 一. master
springboot脚手架 只包含lombok web swagger基础依赖
### 二. annotation-demo
Springboot自定义注解结合AOP实现限流
+ Springboot结合自定义注解的使用
+ Springboot结合aop使用
+ 接口限流思路
### 三. boot-order-demo
springboot初始化资源的几种方式
在Spring Boot中,可以使用多种方式来跟随项目启动,以下是其中的几种方式:
1. 使用CommandLineRunner接口
实现CommandLineRunner接口,并重写run方法,该方法会在Spring Boot应用启动时执行。例如:
```java
@Component
public class MyCommandLineRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
// 在应用启动时执行的代码
}
}
```
2. 使用ApplicationRunner接口
实现ApplicationRunner接口,并重写run方法,该方法会在Spring Boot应用启动时执行。与CommandLineRunner不同的是,ApplicationRunner的run方法接收一个ApplicationArguments对象作为参数,该对象可以获取应用启动时传递的参数。例如:
```java
@Component
public class MyApplicationRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
// 在应用启动时执行的代码
}
}
```
3. 使用@EventListener注解
使用@EventListener注解来监听Spring Boot应用启动事件,例如:
```java
@Component
public class MyEventListener {
@EventListener
public void onApplicationEvent(ApplicationReadyEvent event) {
// 在应用启动时执行的代码
}
}
```
4. 使用ApplicationListener接口
实现ApplicationListener接口,并重写onApplicationEvent方法,该方法会在Spring Boot应用启动时执行。例如:
```java
@Component
public class MyApplicationListener implements ApplicationListener<ApplicationReadyEvent> {
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
// 在应用启动时执行的代码
}
}
```
5. 启动类里直接调用代码
```java
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
System.out.println("启动完成");
GeneralMethod.init();
}
}
```
6. 使用@PostConstruct注解到方法上,当加载bean时会执行
```java
@Component
public class PostConstructTest {
@PostConstruct
public void test() {
System.out.println("this is PostConstruct class");
}
}
```
以上是几种常见的跟随Spring Boot项目启动的方式,可以根据具体需求选择适合的方式。要设置启动顺序时可以通过@order注解来设置顺序,值越小越先加载
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
springboot初始化资源的几种方式源码 (236个子文件)
0100378910df597dd14f601ae38bc49afc5545 227B
0385b142caace3634ceee7cdae7b397a1f9b59 45B
057678d8a419022e1d532ad2b5aec8ddc7ec1a 46B
0ba2750bf4e1ab9f650878966793e05e23a9f2 45B
1311b1e454e0a6544b7a336853659e25a5d528 814B
136dd9403fbec865b5a8d16fb3550d6a994215 166B
1727c1a26ddbab1da5911f9b891800a33d6538 243B
19d3c6b36d2711898ebac735cc05cf9ca1183e 122B
1c055c641de70bdf3d596348f13810061d9072 121B
1c963f08c776ab12c5a770610329a346d1a1a8 225B
21e0e05186dec3cf59c927e232526662a064b2 46B
2b509972da2d85ee29232ba164c34220065b33 65B
2e3252753a4bece3d9f4069a74c531ae314c41 75B
3018a1193d60766c9f934b9ba9d1e2746c44a0 79B
337475452d5643ecbbadb97f7923e9e16423fc 148B
38fc71130c312983a1708f16d9c66cf8b95ba4 46B
390127e9d13fd16f480043f1057a5f1ea7985c 969B
39e145d12e2ccff07ca45ef0fb3efc95b072b3 63B
3aecfac7bf0032d40af91c305c77bfa7be0b4c 81B
3d22266ac8aa2f8df2edef68082c789727841d 24B
3ed101cfb4385e639ccc1315e72e17d3a09144 108B
4290ab6aefe2e796fda0092cd5a49ec5cd5c5a 45B
429e27835e5be06f6be243d48fe1d13bf46c39 283B
46d3d4c23a2d442c22d6f5fa40f8b7e4cc0c34 47B
4780496e4906970592c08c13c83c31628aaf6f 149B
4d81cfb881af5166c6ab3d2f3c1c32cffb944d 511B
506e8f679902682505aec618a455ff781d5b59 441B
55ea7e10bc6e88c48dc6c257240ade71a6b5c6 151B
58f0581328ab6f00a6b89e2467457fb5f47e82 46B
59e87b491a856fcc9c3da10318ca0ae997b8bd 296B
5c82de5981ac5b20156fc83c5749488bdf4665 64B
5c955219c3d6b87bd4795a93417b7974d29045 260B
5ccfafae75328ac51377b8cbd18425e0d85ede 54B
5d2cfe9ddb918774cd5efae244de86a6a39d97 46B
61f2e2b36bfd5d6f4358f9945575ebf9e6fe8e 45B
66bc0f98262f0c5ac3fdc4d8f34979ef993530 161B
66df27d9b64352d4998037033ef5b1bf1daa1e 119B
698baa4721a685bd27831aa40d5e39afd22248 430B
718366f1ae6ef9c5943940f48954e495b80586 116B
721f6e4b4dd09bda8f10297400f40dda7b3c90 889B
74797dce507570aa9b262917e49ee56e743a29 218B
762050a5ff593cc55a5a4580a6b9cf8d657d0a 163B
76258e8a5b2b3e5e80d766e950bd46b63f6683 150B
77066ff1648922589edae0f91062df5eebc341 124B
77a9c0088e3de5d891d88472dcbe534eda6c15 75B
78afee6f28a1440749c1fec156519b57c553a5 45B
7b2d690342ea6bb506e4ba132de2b41ecd706e 272B
7dc3006107504a4eebd3a87e35a8f1e750944d 150B
7e990c045ae3a0bc65c13a0b090112b7975338 202B
7fb24073ffbaf0fa39ff4ea605d5aca8f5d42a 56B
80108356661a64cc943c476379535c9f963a7d 173B
86cdd64ae1b4b935f00c6656d5f5a5beca6a25 506B
8e93e432e877fa7fefc2b128e142650d4d19ad 898B
8fd5a2404db275dd0babf874307bb1b0fa9e82 188B
909734c8d18343e2620b327b185873ef3e07aa 122B
91b8853ef09306744aca79743f09a2f2871c7b 250B
9488c3898b5c35b824ef1c5134a5098bb7a6de 149B
977aef1d86ebd10221d3395d4e04f9aa4a73fb 124B
9d71eb200ebe5e1c4099fcd9f69f391d638f48 64B
9f4fc55f8e1e2e9e379f7a6dfc5a87b37b5ce6 191B
a1084d6190e263e401dcfeca276c750b491534 258B
a2f99cb901478847a085f92f2883ae401698d5 111B
a7b53950cf488f0b0cc507eeb4889dc4c04ac9 33B
afbb51d3aee037978ddab24b6b38f3593b42c6 288B
annotation-demo 469B
annotation-demo 420B
annotation-demo 41B
annotation-demo 41B
b47d96ab426c9192e78e6c62288feff78d8a48 126B
b851b4d8c7022fe6db2b2199d6c8255617eeb0 375B
bb435a5762c7e746c91d0e92f82b53e2b61a31 45B
bc1cbfae35249cd20757e5169c0f007d4b7164 67B
boot-order-demo 325B
boot-order-demo 280B
boot-order-demo 41B
boot-order-demo 41B
c3f253bb52688ffa21fd16effa53e7cc216d97 246B
c95ae61664cded91468aad86b10cbcfa1d49c0 124B
cc3dcc8caa3a2f70da28f2bf1084353c5e0df2 284B
ccecd3dc5c48138fa5d5129261c696581b7f91 150B
cf56e79ca8a1c634a7bab54133d84700c08e0c 120B
cfbfa0df9b494fde98fe4bf01241a688e8a00e 74B
COMMIT_EDITMSG 41B
config 497B
d0af933741a6e09ee7dde5d4e01a78981bfee7 1KB
d9f9d9f01376ebf880f5859252606d0d151b40 159B
db1cbee458b785ef0a005507875e78ad5c2a89 124B
dcb1712d53c82593aeb5b5bf67e2adda187ea2 79B
dcb7faea1ad1b1ae7991ad915b85751e025696 962B
de4cfeb14b292f39b318b55d5fec3bc5a9eda8 250B
description 73B
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
e272b58a019764d9dbf3c91fd82e0f4a3137f6 79B
e32b419b89daa10044625591555c3f75d58103 47B
ef41b165595e5cd751a5e067c5decaa001b715 187B
共 236 条
- 1
- 2
- 3
资源评论
奥兔man
- 粉丝: 2
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功