I’m developing a Spring Boot application that utilizes a JSP front-end alongside a Java back-end. After deploying my project on a Tomcat server, the front-end loads successfully; however, accessing the backend URL results in a 404 error. For instance, visiting http://localhost:8090/orders leads to this issue.
I have properly defined the @RequestMapping
for my endpoints, and I’m using a workbench for database management. Here are my settings in application.properties
:
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
, which has numerous dependencies, I’ve included the key one:
mysql
mysql-connector-java
8.0.11
Here is the relevant code from my controller:
private OrderService orderService;
@RequestMapping("/orders")
public List retrieveOrders() {
return orderService.getAllOrders();
}
And in the service layer:
@Autowired
private OrderRepository orderRepository;
public List getAllOrders() {
List ordersList = new ArrayList<>();
for (Order order : orderRepository.findAll()) {
ordersList.add(order);
}
return ordersList;
}
The repository interface looks like this:
public interface OrderRepository extends CrudRepository {}
I have also created the Order.java
class, which I believe is unrelated to this issue. There are no errors appearing in the terminal, apart from common Tomcat errors.
My Question: Why am I facing a 404 error as mentioned before? I would appreciate any help to identify and resolve this issue.