I am a very newbie in CDI. This is my FIRST example and I am trying to run it. Having searched the internet I wrote the following code: Class that I want to be injected
Either no beans.xml exists within WEB-INF or the file requires changing bean-discovery-mode="annotated" to bean-discovery-mode="all".
The recommended value "annotated" only recognizes annotated CDI managed beans. Beans without any annotation are ignored. As your Temp class is not CDI bean, so recommendation is not applicable in your case.
To work with annotated, annotate the class with @RequestScoped:
// Import only this RequestScoped
import javax.enterprise.context.RequestScoped;
@RequestScoped
public class Temp {
public Temp() { }
public String getMe() {
return "something";
}
}
This RequestScoped will convert your Temp class to CDI bean and will be work with bean-discovery-mode="annotated".