<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
public class Student {
private String name;
private int age;
public Student(String name, int age) {
this.name = name;
this.age = age;
}
// ...
}
public class StudentService {
private Student student;
public StudentService(Student student) {
this.student = student;
}
public void printStudentInfo() {
}
}
import javax.inject.Inject;
public class Main {
@Inject
private static StudentService studentService;
public static void main(String[] args) {
studentService.printStudentInfo();
}
}
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>