import javax.inject.Inject;
public class GreetingService {
@Inject
private MessageService messageService;
public void greet() {
System.out.println(messageService.getMessage());
}
}
import javax.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class MessageService {
public String getMessage() {
return "Hello, World!";
}
}
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2.0.xsd"
bean-discovery-mode="all">
</beans>