My inheritance class refers to the service layer method, the annotated way is @autowired
The note will not report an error if it is referenced after the container tomcat is started, and java.lang.NullPointerException errors will not be reported.
If you want to invoke data from the database at initialization time, the service layer class is not instantiated, causing the tomcat to start the Times null pointer error.
Workaround:
@Component
public class Messageresource extends Abstractmessagesource implements Resourceloaderaware
{
@Autowired
Private Tslanguagetestservice Tslanguagetestservice;
private static Messageresource util;
/**
* Map Segmentation characters
*/
Protected final String Map_split_code = "|";
Private Final map<string, string> properties = new hashmap<string, string> ();
/**
* Initialize the data and read the internationalization of the database into the cached map
*/
@PostConstruct
public void init () {
Util = this;
Util.tslanguagetestservice = This.tslanguagetestservice;
}
}
is primarily the init () method and the @postconstruct annotation, so that the @autowired annotation class is manifested when Tomcat starts
Failed to instantiate [class referencing spring configuration file]: Constructor threw exception; Nested exception is java.lang.NullPointerException