You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://maven-badges.herokuapp.com/maven-central/io.avaje/avaje-inject)
5
5
6
-
# [avaje-inject](https://avaje.io/inject)
6
+
# [Avaje-Inject](https://avaje.io/inject)
7
7
APT based dependency injection for server side developers - https://avaje.io/inject
8
8
9
-
### Example module use
9
+
## Quick Start
10
+
#### 1. Add avaje-inject as a dependency.
11
+
```xml
12
+
<dependency>
13
+
<groupId>io.avaje</groupId>
14
+
<artifactId>avaje-inject</artifactId>
15
+
<version>${avaje.inject.version}</version>
16
+
</dependency>
17
+
```
18
+
#### 2. Add avaje-inject-generator annotation processor as a dependency with provided scope.
19
+
```xml
20
+
<dependency>
21
+
<groupId>io.avaje</groupId>
22
+
<artifactId>avaje-inject-generator</artifactId>
23
+
<version>${avaje.inject.version}</version>
24
+
<scope>provided</scope>
25
+
</dependency>
26
+
```
27
+
If there are other annotation processors and they are specified via `maven-compiler-plugin`, then we add avaje-inject-generator there instead.
28
+
```xml
29
+
<plugin>
30
+
<groupId>org.apache.maven.plugins</groupId>
31
+
<artifactId>maven-compiler-plugin</artifactId>
32
+
<configuration>
33
+
<annotationProcessorPaths> <!-- All annotation processors specified here -->
34
+
<path>
35
+
<groupId>io.avaje</groupId>
36
+
<artifactId>avaje-inject-generator</artifactId>
37
+
<version>${avaje.inject.version}</version>
38
+
</path>
39
+
<path>
40
+
... other annotation processor ...
41
+
</path>
42
+
</annotationProcessorPaths>
43
+
</configuration>
44
+
</plugin>
45
+
```
46
+
#### 3. Create a Bean Class annotated with @Singleton
47
+
```java
48
+
@Singleton
49
+
publicclassExample {
10
50
51
+
privateDependencyClass d1;
52
+
privateDependencyClass2 d2;
53
+
54
+
// Dependencies must be annotated with singleton,
55
+
// or else be provided from another class annotated with @Factory
0 commit comments