Java SE CDI maven dependencies?
public class FooProcessor {
private FooService fooService;
@Inject
public FooProcessor(FooService fooService) {
this.fooService = fooService;
}
}
What are the jar dependencies for CDI for Java SE?
Which jar dependency has @Inject? Tried
compile "org.jboss.weld.se:weld-se-core:3.0.2.Final"
compile 'org.apache.deltaspike.cdictrl:deltaspike-cdictrl-api'
compile group: 'javax.enterprise', name: 'cdi-api', version: '2.0.SP1'
compile group: 'javax', name: 'javaee-api', version: '7.0'
You can configure CDI in standalone mode by using Weld
reference implementation.
Example:
Weld weld = new Weld();
WeldContainer container = weld.initialize();
FooProcessor fooProcessor = container.instance().select(FooProcessor.class).get();
weld.shutdown();
and weld dependency
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>3.1.4.Final</version>
</dependency>
Regarding @Inject
it coming from
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
and this coming from JSR 330: Dependency Injection For Java
that introduces a standard set of annotations that can be used for dependency injection.