| name | avaje-inject |
|---|---|
| description | Avaje Inject compile-time DI framework with avaje-config. Bean creation, factories, qualifiers, lifecycle, configuration, testing. Use when working with avaje-inject outside of avaje-nima (e.g., with Ebean standalone, CLI tools). |
Avaje Inject is a compile-time dependency injection framework for Java. No runtime reflection, no proxies — all DI code is generated at compile time via annotation processing.
- Compile-time code generation — fast startup, GraalVM native image ready
@Singleton/@Componentfor beans,@Factory+@Beanfor factory methods- Constructor injection preferred, field/method injection supported
@InjectTest+@TestScopefor testing- Pairs naturally with avaje-config for external configuration
Load the relevant reference guide for the current task. Only load what you need.
| Task | Reference |
|---|---|
| Project setup, adding dependencies | setup |
| Beans, factories, qualifiers, lifecycle | dependency-injection |
| Configuration, profiles, env vars | configuration |
| Testing with @InjectTest | testing |
@Singleton
class CustomerService {
private final Database database;
@Inject
CustomerService(Database database) {
this.database = database;
}
}@Factory
class AppConfig {
@Bean
Database database(Configuration config) {
return Database.builder()
.name("db")
.dataSourceBuilder(...)
.build();
}
}@InjectTest
class CustomerServiceTest {
@Inject CustomerService service;
@Test
void find() {
assertThat(service).isNotNull();
}
}@TestScope
@Factory
class TestConfig {
@Bean
Database database() {
// test-only Database bean
}
}# application.yaml
myapp:
feature.enabled: trueboolean enabled = Config.getBool("myapp.feature.enabled", false);cd /path/to/avaje/skills && ./generate-references.sh