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
使用しているライブラリのバージョンを追加してください。クラスパスに適切なjacksonライブラリを追加するだけで、うまくいくはずです。春に使用されたバージョンを取得するには、春のポンを確認してください。 –