Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
952 views
in Technique[技术] by (71.8m points)

dependency injection - @PostConstruct is not called in @RequestScoped

I heav the following bean

@RequestScoped public class MyJWT {

@Inject
JsonWebToken jwt;

private User loggedUser;
private String rawToken;

@PostConstruct
public void init() {
    if (jwt != null && jwt.getRawToken() != null) {
        this.loggedUser = User.findByEmail( jwt.getClaim(Claims.email.name()).toString());
        this.rawToken = jwt.getRawToken();
    }
}

but I don't see init is called ever. I mean, my debugger doesn't stop on any breakpoints inside. In case debugger is confused by instrumentation, I was also trying to add exception throwing inside, but didn't see any effect.

How is this possible?

question from:https://stackoverflow.com/questions/65848190/postconstruct-is-not-called-in-requestscoped

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...