to {GET [/orders/history]}: There is already 'orderController' bean method

what im i doing wrong here seems something with the path but chaning it doesn t seem to work
5 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @timo! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Timo
TimoOP10mo ago
@RestController
@CrossOrigin(origins = "http://localhost:4200")
@RequestMapping("/orders")
public class OrderController {
private final OrderService orderService;

@Autowired
public OrderController(OrderService orderService) {
this.orderService = orderService;
}

@PostMapping
public ResponseEntity<Order> placeOrder(@RequestBody OrderDTO orderDTO, Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.placeOrder(orderDTO, principal.getName()));
}

@GetMapping("/history")
public ResponseEntity<List<HistoryOrderDTO>> getOrderHistory(Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.findOrdersByCustomUser(principal.getName()));

}

@GetMapping("/history")
public ResponseEntity<List<HistoryOrderDTO>> getallOrder(Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.findOrdersByCustomUser(principal.getName()));

}

@GetMapping("/forall")
public ResponseEntity<List<OrderDTO>> findAllOrders(Principal principal) throws Exception {
if (principal == null) throw new Exception();

return ok(orderService.findAllorders());
}

@DeleteMapping("/{id}")
public ResponseEntity<String> deleteById(@PathVariable Long id){
this.orderService.deleteById(id);
return ok("Order deleted with id " + id);
}
}
@RestController
@CrossOrigin(origins = "http://localhost:4200")
@RequestMapping("/orders")
public class OrderController {
private final OrderService orderService;

@Autowired
public OrderController(OrderService orderService) {
this.orderService = orderService;
}

@PostMapping
public ResponseEntity<Order> placeOrder(@RequestBody OrderDTO orderDTO, Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.placeOrder(orderDTO, principal.getName()));
}

@GetMapping("/history")
public ResponseEntity<List<HistoryOrderDTO>> getOrderHistory(Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.findOrdersByCustomUser(principal.getName()));

}

@GetMapping("/history")
public ResponseEntity<List<HistoryOrderDTO>> getallOrder(Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.findOrdersByCustomUser(principal.getName()));

}

@GetMapping("/forall")
public ResponseEntity<List<OrderDTO>> findAllOrders(Principal principal) throws Exception {
if (principal == null) throw new Exception();

return ok(orderService.findAllorders());
}

@DeleteMapping("/{id}")
public ResponseEntity<String> deleteById(@PathVariable Long id){
this.orderService.deleteById(id);
return ok("Order deleted with id " + id);
}
}
szatkus
szatkus10mo ago
You have @GetMapping("/history") defined twice.
Timo
TimoOP10mo ago
oh uh lol think created one on accident when trying to create my func lol thx !resolved "message": "Could not write JSON: class java.util.ArrayList cannot be cast to class org.hibernate.mapping.List (java.util.ArrayList is in module java.base of loader 'bootstrap'; org.hibernate.mapping.List is in unnamed module of loader 'app')",
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?