title: HttpMessageNotWritableException: No converter found for return value of type: class java.util.HashMap in Spring MVC
body: <p>I am trying to return a json using HashMap like this in a method in the controller</p>
  
  <pre><code>//list all users
      @RequestMapping(value = "/user",method = RequestMethod.GET)
      public ResponseEntity&lt;Map&lt;String,Object&gt;&gt; handleRequest() throws Exception{
          List&lt;User&gt; users = userService.list();          
          Map&lt;String, Object&gt; message = new HashMap&lt;String, Object&gt;();
  
          message.put("severity", "info");
          message.put("user", users);
          message.put("summary", "Not successfully.");
          message.put("code", 200);
  
          Map&lt;String, Object&gt; json = new HashMap&lt;String, Object&gt;();
          json.put("success", true);
          json.put("message", message);
  
          return new ResponseEntity&lt;Map&lt;String,Object&gt;&gt;(message,HttpStatus.CREATED);
      }
  </code></pre>
  
  <p>When I hit this method in PostMan I get this error</p>
  
  <pre><code>org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class java.util.HashMap
  org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:226)
  org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:180)
  org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:82)
  org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:119)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
  org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>This is how I have setuped the Application </p>
  
  <pre><code>@Configuration
  @ComponentScan("com.fyt.fyt")
  @EnableTransactionManagement
  public class ApplicationContextConfig {
  
  
      @Bean
      public InternalResourceViewResolver getViewResolver() {
          InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
          internalResourceViewResolver.setPrefix("/WEB-INF/views/");
          internalResourceViewResolver.setSuffix(".jsp");
          return internalResourceViewResolver;
      }
  
      @Bean
      public DataSource getDataSource() {
          BasicDataSource dataSource = new BasicDataSource();
          dataSource.setDriverClassName("com.mysql.jdbc.Driver");
          dataSource.setUrl("jdbc:mysql://localhost:3306/fyt");
          dataSource.setUsername("root");
          dataSource.setPassword("");
          return dataSource;
      }
  
      @Bean
      public LocalSessionFactoryBean getSessionFactory() {
  
          LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
          factoryBean.setDataSource(getDataSource());
          factoryBean.setHibernateProperties(getHibernateProperties());
          factoryBean.setAnnotatedClasses(User.class);
          return factoryBean;
  
      }
  
      private Properties getHibernateProperties() {
          Properties properties = new Properties();
          properties.put("hibernate.show_sql", "true");
          properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
          return properties;
      }
  
      @Bean
      public HibernateTransactionManager getTransactionManager() {
          HibernateTransactionManager transactionManager = new HibernateTransactionManager();
          transactionManager.setSessionFactory(getSessionFactory().getObject());
          return transactionManager;
      }
  
      @Bean
      public UserDao userDao() {
          return new UserDaoImpl();
      }
  }
  </code></pre>
  
  <p>The error says, it cannot convert the list to httpmessges so do I need to any any converters or something like that? What am I missing something?</p>