When I reference the bean from the constructor it is null, but when referenced from another method it is fine.
Asked
Active
Viewed 597 times
0
-
1You'd really benefit from providing some more details. Any code you can share? – johnnyRose Aug 08 '15 at 01:27
-
Possible duplicate of http://stackoverflow.com/questions/6335975/autowired-bean-is-null-when-referenced-in-the-constructor-of-another-bean tldr: try using @PostConstruct if you need access to beans during class initialization – lux Oct 01 '15 at 15:47
1 Answers
0
To refer a bean in a constructor, you need to
- Annotate the constructor with
@Autowired
- Pass the bean as a parameter to the constructor
More details can be diagnosed if you share some sample code.

Sanjay
- 8,755
- 7
- 46
- 62