java - Monitor bean injection failure -
we have application spring beans (3 levels) running on tomcat, beans annotated @autowired , mandatory. what monitor bean injection failure (which can indicate deployment problem). the way i'm thinking have 2 options so: instead of using @autowired load beans in static block, if load fails do something surround code try{...} catch (nullpointerexception e) , if bean null exception thrown. check if beans equal null @ every method. i think #1 elegant , least amount of code add, wondering whether there elegant way without static block. thanks there quiet few options here. favorite annotate required dependency @autowired(required=false) , in method anotated @postconstruct test , handle missing dependency: ... @autowired(required = false) private bean dependency; @postconstruct private void init() { if(dependency==null) { // handle missing dependecy } } there quiet interesting article checking of required dendecies in spring. it's bit ol...