我有一个简单的RESTful Java Web服务......
@Service
@Path("/getAccountBalance")
public class GetAccountBalanceService {
@Autowired
private ILicenseService licenseService;
@GET
@Path("/{param}")
public Response provideService(@PathParam("param") String licenseUUID) {
License license = this.licenseService.getByUUID(licenseUUID);
String output = "Balance on the account : " + license.getBalanceValue();
return Response.status(200).entity(output).build();
}
起初我得到一个错误,即bean licenseService为null,即使我正在自动装配它。所以基于来自另一个post的建议,我开始使用Spring servlet作为jersey,因此在我的web-xml中,我从com.sun.jersey.spi.container.servlet.ServletContainer更改为...
<servlet>
<servlet-name>jersey-servlet</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.freedomoss.crowdcontrol.api</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
但是现在当我启动Tomcat时,我收到错误..
Dec 19, 2014 12:13:13 AM org.apache.catalina.startup.ContextConfig applicationWebConfig
SEVERE: Parse error in application web.xml file at jndi:/localhost/mturk-web/WEB-INF/web.xml
java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name jersey-serlvet
为什么会这样?如您所见,在web-xml中有一个使用该名称定义的servlet。如果加载该servlet有什么问题,为什么不记录这个故事?
感谢。