I am developing an application using Spring Boot, which includes a JSP front end and a Java back end. Once I deploy the application on a Tomcat server, the front end loads successfully. However, attempting to access a specific URL to evaluate the back end functionality results in a 404 error.
Example URL: http://localhost:8090/orders
I’ve ensured that the @RequestMapping
paths are set up correctly and I am employing Workbench for my database management.
Here is part of my application.properties
file:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/csse_ass
spring.datasource.username=root
spring.datasource.password=1234
spring.jpa.hibernate.ddl-auto=create
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
In my pom.xml
file, I’ve included the necessary dependency:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
Here’s the controller snippet:
private OrderService orderService;
@RequestMapping("/orders")
public List<Order> fetchAllOrders() {
return orderService.fetchAllOrders();
}
In the service layer:
@Autowired
private OrderRepository orderRepo;
public List<Order> fetchAllOrders() {
List<Order> orderList = new ArrayList<>();
for (Order order : orderRepo.findAll()) {
orderList.add(order);
}
return orderList;
}
And the repository interface looks like this:
public interface OrderRepo extends CrudRepository<Order, String> {}
I have an Order.java
class as well, but I don’t believe it plays a role in this issue. I’m not encountering any errors in my terminal apart from the usual Tomcat notices.
Question: What could be causing the redirection to the 404 page as mentioned at the start? I’m seeking assistance to resolve this issue as I am unable to identify the root cause.