Ninjector
Ninjector - the cure for Field Injection Anxiety
Install / Use
/learn @odrotbohm/NinjectorREADME
= Ninjector
Ninjector is the cure for a disease called Field Injection Anxiety, widely diagnosed amongst software developers that care about their code. The disease is caused by injection frameworks all too easily allowing http://www.martinfowler.com/articles/injection.html[dependency injection] into a class' fields which seems to be a convenient thing to do in the first place but will inevitably bite you in the back later on. For a more detailed analysis of symptoms and consequences, see http://olivergierke.de/2013/11/why-field-injection-is-evil[this blog post]
== What does it do?
@Configuration
@ComponentScan
@DisableFieldInjection
class Application { … }
/**
* This class will fail the ApplicationContext to bootstrap
* due to the injection annotation used on a field.
**/
@Component
class ApplicationComponent {
@Autowired MyCollaborator collaborator;
}
@DisableFieldInjection registers a tiny Spring extension that will pre-process the bean instances about to be created, scan their fields for common injection annotations (e.g. @Inject, @Autowired, @Resource) and reject the bean instantiation right away.
Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
