0
저는 Maven, Spring 및 CXF를 처음 사용하고 있으며 현재 REST 서비스를 사용할 수있는 곳으로가는 작은 'Hello World'를 얻으려고하고 있습니다. 나는 이것에 하루를 보내고 아직도 나는 두려워하는 "서비스를 찾지 못했습니다."를 얻고 있습니다. Eclipse 내 Tomcat에서 프로젝트를 실행할 때 오류가 발생합니다. 아래에서는 몇 가지 파일에서 중요한 코드를 게시했습니다. 나는 누군가가 내가 잘못 뭘하는지 말해 줄 수 바라고 있어요 :"서비스를 찾을 수 없습니다." 오류
의 web.xml :
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/beans.xml</param-value>
</context-param>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
beans.xml 환경 :
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="bookserviceclass" class="org.ahmad.restTest1.restServices.BookService" />
<jaxrs:server id="bookservice" address="/">
<jaxrs:serviceBeans>
<ref bean="bookserviceclass" />
</jaxrs:serviceBeans>
</jaxrs:server>
</beans>
BookService.java :
package org.ahmad.restTest1.restServices;
import org.ahmad.restTest1.vo.BookVO;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
@Path("/")
public class BookService {
private static HashMap < BookVO, BookVO > hashMap;
@GET
@Path("/randomMsg/{name}")
@Produces({
MediaType.APPLICATION_JSON
})
public Response getSomeMessage(@PathParam("name") String name) {
return Response.ok(name + "123").build();
}
}
감사를 실행 사용할 수 있습니다. 귀하의 솔루션이 나를 위해 일했습니다! – Ahmad