Phenomenon:
@autowired injection service or DAO failed in action, NULL pointer exception
Reason:
The reason for this problem is that you are not doing a good job of integrating spring and jersey, checking your web.xml files, Jersey configuration is certainly the following,
<servlet>
<servlet-name>JerseyServlet</servlet-name>
<servlet-class> com.sun.jersey.spi.container.servlet.servletcontainer</servlet-class>
<init-param>
< Param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.demo</ param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</ servlet>
<servlet-mapping>
<servlet-name>JerseyServlet</servlet-name>
< Url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Solutions:
First you need to confirm whether the Jersey-spring.jar jar package has been introduced, and if not, import it first.
Second, change the configuration of the jersey to the following,
<servlet>
<servlet-name>JerseyServlet</servlet-name>
<servlet-class> com.sun.jersey.spi.spring.container.servlet.springservlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.demo </param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</ servlet>
<servlet-mapping>
<servlet-name>JerseyServlet</servlet-name>
< Url-pattern>/rest/*</url-pattern>
</servlet-mapping>
As you may have seen, the difference lies in the Servlet-class class.