Spring 3.0 MVC를 사용하여 REST를 개발하고 싶습니다 ... 아주 간단한 코드를 테스트했지만 org.springframework.beans.factory.BeanCreationException이 발생했습니다.Spring MVC REST : org.springframework.beans.factory.BeanCreationException이 발생했습니다.
@Controller
public class RestTest {
@RequestMapping(method=RequestMethod.GET, value="/1",
headers="Accept=application/json")
public @ResponseBody Employee getEmp(@PathVariable String id) {
Employee e = new Employee("helloWorld","stip of world");
return e;
}
}
콩-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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<bean id="jsonConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>
<context:component-scan base-package="org.stip.rest"></context:component-scan>
</beans>
예외 :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Cannot resolve reference to bean 'jsonConverter' while setting bean property 'messageConverters' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jsonConverter' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.isFullyTyped()Z
여기 내 코드입니다 jackson-core.jar 및 jackson-mapper가 빌드 경로에 추가되었습니다 ... 최선을 다해 노력하지만 .. 도와주세요 ... 감사합니다.
어떤 jackson 버전을 사용하고 있습니까? Spring 3과의 호환성을 확인 했습니까? –
@AravindA 1.90..i는 호환성을 확인하지 않았습니다 ... 어느 버전이 더 낫습니까? – user996505
사용중인 라이브러리의 버전을 추가하십시오. 당신은 classpath에 바로 jackson 라이브러리를 추가하면된다. 봄철에 사용 된 버전을 확인하려면 봄철 pom을 확인하십시오. –