Comments (4)
我下载到源码后 必须在rateLimiter这个变量上加@Autowired这个注解才能注册进去值 否则 打印出来rateLimiter为空
是我的环境的问题?还是框架有问题呢?
有没有增加启动注解@EnableSyjRateLimit呢,如果增加了启动注解的话会在EnableSyjRateLimitConfiguration这个类里面自动装配的
from syj-ratelimit.
@EnableSyjRateLimit 这个注解加了
EnableSyjRateLimitConfiguration这个类确实会在spring容器中放入 一个RateLimiter类型的对象
但是 在 TokenBucketAlgorithmImpl 这个类里面 的 rateLimiter 这个属性 没有@Autowired 在consume方法中用的时候 会报空指针异常
假如不加这个注解 @Autowired ;是什么原理把rateLimiter 注入到TokenBucketAlgorithmImpl 这个类里面的呢
from syj-ratelimit.
@EnableSyjRateLimit 这个注解加了
EnableSyjRateLimitConfiguration这个类确实会在spring容器中放入 一个RateLimiter类型的对象
但是 在 TokenBucketAlgorithmImpl 这个类里面 的 rateLimiter 这个属性 没有@Autowired 在consume方法中用的时候 会报空指针异常
假如不加这个注解 @Autowired ;是什么原理把rateLimiter 注入到TokenBucketAlgorithmImpl 这个类里面的呢
这个对象注入主要是使用了Lombok插件的@requiredargsconstructor,这个注解为类提供了一个包含带有@nonnull注解变量的构造方法,Spring在执行时就会自动把这些变量注入进去。你的情况可能是因为本地开发工具没有集成Lombok的原因。可以选择使用maven**仓库的依赖或者开发工具增加Lombok集成环境
from syj-ratelimit.
嗯 应该是这个原因
from syj-ratelimit.
Related Issues (7)
- 计算令牌数取整 HOT 1
- redis适用于集群部署 HOT 1
- 开源登记
- 令牌桶算法问题 HOT 1
- 令牌通算法脚本的BUG HOT 1
- 关于lua脚本的疑问 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from syj-ratelimit.