简体   繁体   中英

Lazy init doesn't work in Spring MVC 3

I'm facing a problem with Spring dependency injection. I have an application that once deployed checks if it's previously configured, if not then it launches configuration manager and asks the user for db host, port, admin login and pass etc.

Now I can't find a way to inject those configured values. I assume that I would have to use lazy init beans but when i add the annotation @Lazy, Spring is still trying to inject them at the runtime and I'm getting an error since the host and port are not yet configured. What am I missing :/?

You need a lookup method , a feature accessible only through XML configuration. There is an almost ancient JIRA issue still open on this, still unresolved.

Please do check this comment on the mentioned issue, it describes a workaround that may be an option for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM