RestController
にリクエストを渡すと、次のエラーが発生します。ここでSpring FrameworkのXmlBeanDefinitionStoreException:要素 "beans:bean"の接頭辞 "beans"がバインドされていません
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 22 in XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 108; The prefix "beans" for element "beans:bean" is not bound.
org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 108; The prefix "beans" for element "beans:bean" is not bound.
はコントローラです:
@RestController
public class smsController {
@RequestMapping(value = "/sendSMS", method = RequestMethod.POST)
public void sendMessage(@RequestBody MessageBean msgBean) throws UnsupportedEncodingException {
String numbers = msgBean.getNumbers();
String message = msgBean.getMessages();
}
}
そしてdispatcher-servlet xml
:クラスパス上の
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.spring.rest.controllers" />
<mvc:annotation-driven />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
<beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<beans:property name="messageConverters">
<beans:list>
<beans:ref bean="jsonMessageConverter"/>
</beans:list>
</beans:property>
</beans:bean>
</beans>
ジャー:
jackson-annotations-2.3.2.jar
jackson-databind-2.3.2.jar
jackson-core-2.3.2.jar
私が問題を引き起こしているかわからないです。私はjackson 2.7.4
の新しいjarファイルを使用する場合、私は別のエラーを取得:
java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonTypeInfo$As
デフォルトの名前空間は、設定をより簡潔にしておく方がよいでしょう。 –
jacksonの要求ハンドラマッピングが必要ですか?私はこれでかなり新しいです。接頭辞を削除すると、エラーが発生します。原因:org.springframework.beans.factory.NoSuchBeanDefinitionException: 'jsonMessageConverter'という名前のBeanが定義されていません。 – Satyadev
classpthに 'jackson-databind'の依存関係がある場合は、それ。 –