I am trying to inject a bean into an enum but i keep getting null pointer exception when call to someMethod is made.
The answer mentioned in this Inject bean into enum worked for me. I want to know why my code didn't work
@Component
public class DataProvider {
public int method1() {
//somecode
}
}
public enum Genres {
DRAMA(1,”Drama”);
ADVENTURE(2,”Adventure”);
HORROR(3,”Horror”);
private int id;
private String name;
@Inject DataProvider dataprovider;
public int someMethod() {
return dataprovider.method1();
}
}