Java Spring引导RESTful应用程序错误

Java Spring引导RESTful应用程序错误,java,spring,mongodb,spring-mvc,Java,Spring,Mongodb,Spring Mvc,我正在开发一个简单的Spring Boot RESTful应用程序,除了列出所有客户(从Mongodb检索所有客户)之外,其他一切都很好。用我目前的代码,我应该可以检索所有的客户 每次我在浏览器中键入http://localhost:8080/customers我收到一个错误 从我的Java类CustomerRestController: @CrossOrigin @GetMapping("/customers") public ArrayList<Customer>

我正在开发一个简单的Spring Boot RESTful应用程序,除了列出所有客户(从Mongodb检索所有客户)之外,其他一切都很好。用我目前的代码,我应该可以检索所有的客户

每次我在浏览器中键入
http://localhost:8080/customers
我收到一个错误

从我的Java类CustomerRestController:

@CrossOrigin
    @GetMapping("/customers")
    public ArrayList<Customer> getCustomers()
    {
        customerDAO = new CustomerDAO();
        return customerDAO.getCustomers();
    }

你的代码有点不正确。更新以下行:

$.getJSON("http://localhost:8080/customers/",  function(data)
对下列事项:

$.getJSON("http://localhost:8080/customers",  function(data)

url与ReST端点之间存在差异。

能否共享CustomerDAO类?似乎
list.get(1).toString()
返回字符串
com.myproject.model.Customer
,而不是浮点数。也许您没有注意到
List
索引是基于零的,实际上是指
Float.parseFloat(List.get(0.toString())
?我认为这不是索引问题。我尝试了你的建议,下面的答案没有解决问题:(我尝试了你的建议。不幸的是,它没有解决错误:)?
Whitelabel Error Page
    This application has no explicit mapping for /error, so you are seeing this as a fallback.
    Fri Mar 17 23:48:40 EET 2017
    There was an unexpected error (type=Internal Server Error, status=500).
    For input string: "com.myproject.model.Customer"
$.getJSON("http://localhost:8080/customers/",  function(data)
$.getJSON("http://localhost:8080/customers",  function(data)