170616、解決 java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList
阿新 • • 發佈:2017-08-20
pen group string image exception bean val 轉換 技術
報錯截圖:
原因:搭建項目的時候,springmvc默認是沒有對象轉換成json的轉換器的,需要手動添加jackson依賴。
解決步驟:
1、添加jackson依賴到pom.xml
<!-- jaskson --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.5.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.4</version> </dependency>
2、在springmvc.xml增加
<mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframework.http.converter.StringHttpMessageConverter"/> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/> </mvc:message-converters> </mvc:annotation-driven>
然後問題解決
170616、解決 java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList