For reference and reference: http://blog.csdn.net/ohalo/article/details/48999863
Wrong spelling:
@Autowired private static OpenSearchProperties openSearchProperties;
This writing error: Autowired annotation is not supported on static fields
Solution 1: Just don't use static (if you have to use it, please see solution 2)
Solution two:
private static OpenSearchProperties openSearchProperties; @Resource(name = "openSearchProperties") public void setOpenSearchProperties(OpenSearchProperties openSearchProperties) { OpenSearchUtil.openSearchProperties = openSearchProperties; }
Among them, openSearchProperties in @Resource(name = "openSearchProperties") is the spring dependency injection class such as serice, dao, Component, Configuration, etc. that you want to import