I have spent the last 2 hours trying to figure out just what in gods name is going on with my simple springboot rest app.
NO matter what I do, I simply cannot get the restcontroller to work, every URL I try gives me a 404. Here is my code below.
@RestController
public class PbxPortalRestControllerSet {
@RequestMapping("/testMe")
public String testMe()
{
return "I am alive";
}
}
@SpringBootApplication
public class PbxPortalApplication {
public static void main(String[] args) {
SpringApplication.run(PbxPortalApplication.class, args);
}
}
Application.properties file
server.port = 8088
can anyone tell what the heck is going on? I have done this tons of times before, but I can't for the life of me figure out why this refuses to work.
I try to to go to localhost:8088/testMe, and I get a 404.
It seems that you are you have placed your controller different sub package than spring SpringApplication file. So Controller is not accessible from Spring main() Please add
CodeSnipet:SpringBootApplication
CodeSnipet:Controller
application.properties file
NB: Best way to put in same package or put controller class in sub-package
Main Class is simple:
Can you try this once ?? And see if it works..
Basically sometimes when you dont provide the request method type you get such types of errors
I found the issue. I was using the wrong POM entry. I was using Jersey somehow instead of the built in spring ones. For some reason even though I was using the wrong library, eclipse was telling me that my annotation entries were perfectly fine. Once i deleted the entry for Jersey everything worked
If
PbxPortalApplication
andPbxPortalApplication
classes are in different package, you need to tell your application to scan the controller while loading up the app context.Add the
@ComponentScan
to yourPbxPortalApplication
class