@Inject and @PostConstruct not working in singleton pattern
问题 I have a class as below: public class UserAuthenticator { private static UserAuthenticator authenticator = @Inject private UserRepository userRepository; @PostConstruct public void init() { List<User> allUsers = userRepository.findAll(); for (User user : allUsers) { users.put(user.getEmail(), user.getPassword()); serviceKeys.put(user.getServiceKey(), user.getEmail()); } } public static UserAuthenticator getInstance() { if (authenticator == null) { authenticator = new UserAuthenticator(); }