How can I access to @Value annotated variable from Constructor?

Use PostConstruct on your init() method - it will be called by spring as soon as the object is inside the spring context, which means all if its dependencies will be injected.

Use @PostConstruct on your init() method - it will be called by spring as soon as the object is inside the spring context, which means all if its dependencies will be injected.

Think about it: for spring to inject something into your bean, it needs to be created first, and it isn't created until the constructor has finished its job. You can either create the list lazily, or you can implement the spring interface InitializingBean. In your case public class MainNavs implements Iterable, InitializingBean { ... public void afterPropertiesSet() throws Exception { for (int I = 0; I Length; i++) { navs.add(new Nav(namesi, idsi)); } }.

1 InitializingBean is fine, but I suggested @PostConstruct because he seems to be using the annotation approach. – Bozho Aug 31 at 7:29 yes, I agree, just couldn't remember the annotation ;-) – forty-two Aug 31 at 7:55.

As a work around you could use a factory pattern, something like: public class MainNavs implements Iterable{ // ... public init() throws Exception { for (int I = 0; I.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions