In spring boot there is such a great thing for returning JSON's with automatic pulling it out of the class:

 @RestController public class TaskController { private DBService dbService = new DBService(); @RequestMapping(value = "/tasks") @CrossOrigin public @ResponseBody List<TaskDataSet> tasks() { try { List<TaskDataSet> tasks = dbService.getAllTasks(); return tasks; } catch (DBException e) { System.out.println(e); e.printStackTrace(); } return null; } } 

If you feed this spring mvc code, you get the following error:

 HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList 

How do i do the same in spring mvc right?

  • HTTP Status 500 you get in the browser, what is the error on the server side, is there a wall-race? - Bohdan Korinnyi

2 answers 2

Add a dependency to the project if you have a maven collector or an appropriate gradle

 <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.0</version> </dependency> 

    Judging by the description of the error, spring cannot find a marshaling converter in json .

    To correct the error you need:

    • either connect it separately, as described in its answer @BogdanK ,

    • or add spring dependency:

       <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.3.3.RELEASE</version> </dependency> 

    The controller should look like this:

     @RestController @RequestMapping("/") public class MyController { @RequestMapping(value = "check", method = RequestMethod.GET) public List<Simple> check() { List<Simple> result = new ArrayList<>(); result.add(new Simple()); return result; } } 

    And the model:

     @JsonAutoDetect public class Simple { private int value; }