404-not-found-while-running-spring-boot-rest-api
I got the solution. It was due to package visibility.
Main class was not able to find package in which controller class is present.
So, I added all classes under the same package. You can also place application class one level up.
Got help from below link:
Spring Boot: Cannot access REST Controller on localhost (404)
How to return 404 response status in Spring Boot @ResponseBody - method return type is Response?
Create a NotFoundException
class with an @ResponseStatus(HttpStatus.NOT_FOUND)
annotation and throw it from your controller.
@ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "video not found")
public class VideoNotFoundException extends RuntimeException {
}
Rest API response 404 Not found when run project with Java Application
When you run your project as jar (java application), you should use localhost:8080/demo/user
When you run your application into a server (jboss per example) the name of your war file is the root path.
localhost:8080/MySecret/demo/user
I think your war file is MySecret.war.
That's the reason of the difference between the first and the second. Since you don't have a base path, /demo/user is the path of your endpoint.
Spring boot gives 404 status although request comes into endpoint
I solved the issue. That is my mistake. I forgot to return ResponseEntity as the response. After returning ResponseEntity, the problem is solved...
Related Topics
@Autowired - No Qualifying Bean of Type Found for Dependency
Spring Boot Rest API Returns 404
Error Creating Bean With Name and Singleton Bean Creation Not Allowed
Include Comma in a Field Value of CSV (Delimeter as Comma) in Java
Java.Lang.Illegalargumentexception: No Converter Found for Return Value of Type
How to Properly Use Enums With Multiple Values
Re-Prompt User After Invalid Input in Java
How to Load 100 Million Rows in to Memory
Hibernate Error Executing Ddl Via Jdbc Statement
How Is This Wrong - Hackerrank Loop in Java
The Import Android.Support Cannot Be Resolved
Checking for Null on a Collection in Jpql Queries
Base64: Java.Lang.Illegalargumentexception: Illegal Character
How to Set the Timeout for a Jax-Ws Webservice Client
Empty Check With String[] Array
Reading a Resource File from Within Jar
Why Does Intellij Idea Suddenly Not Recognize Tests in Test Folder Anymore
Spring Junit: How to Mock Autowired Component in Autowired Component