Aware

BeanNameAware

beanNameAware可以获得容器中Bean的名称,作用于每一个Bean。当bean被创建的时候设置他的名字,在基本properties填充完成以后,init调用前执行

摘自: spring-beans:5.3.4 org.springframework.beans.factory.BeanNameAware

Set the name of the bean in the bean factory that created this bean.

Invoked after population of normal bean properties but before an init callback such as {@link InitializingBean#afterPropertiesSet()} or a custom init-method.

1
2
3
4
5
6
7
8
9
10
11
12
package com.example.demo;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Component;

@Component
public class BeanNameAwareDemo implements BeanNameAware {
@Override
public void setBeanName(String name) {
System.out.println(name);
}
}

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial Feign1234567891011121314151617181920212223242526272829303132333435363738394041424344import com.fasterxml.jackson.databind.DeserializationFeature;import com.fasterxml.jackson.databind.ObjectMapper;import...

Guava

RateLimiter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
RateLimiter rateLimiter = RateLimiter.create(10);
for (int i = 0; i < 20; i++) {
int finalI = i;
new Thread(new Runnable() {
@Override
public void run() {
int cnt = 0;
while (true) {
if (rateLimiter.tryAcquire()) {
cnt++;
System.out.println("thread: " + finalI + " cnt: " + cnt);
}
}
}
}).start();
}
Thread.sleep(1000 * 100 * 1000);

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial SSH Install1234567891011# 必须安装passwdyum install openssh-server openssh-clients passwd -y; \sed -i &quot;s/^UsePAM yes/UsePAM no/g&quot; /etc/ssh/sshd_config; \echo 123456 | passwd root...

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial Linux换源 https://zhuanlan.zhihu.com/p/61228593 12345678910111213141516171819sudo cp /etc/apt/sources.list /etc/apt/sources.list_backupsudo vi /etc/apt/sources.list## 添加在最前面deb...