java - AWS EC2, Tomcat7, Spring Boot, web, mvc, REST - http get method is not working -
i have developed "hello-world" web application using spring boot , locally (on embedded tomcat) works fine.
but when uploaded war file tomcat7 installed on aws ec2 have problems invoking simple http methods - getting http:/ /my_server_address:8080/ping 404 (not found).
all static resources works ok (html, css files).
my controller looks like:
@restcontroller public class pingcontroller { @requestmapping(value = "/ping", method = requestmethod.get) public string ping() { return "live!"; } }
my main class looks like:
@springbootapplication public class servletinitializer extends springbootservletinitializer { @override protected springapplicationbuilder configure(springapplicationbuilder application) { return application.sources(servletinitializer.class); } public static void main(string[] args) { springapplication.run(servletinitializer.class, args); } }
i assume have problem dispatcherservlet? don't have web.xml - simple application.properties
can me? in advance!
yes, you're right have issue dispatcherservlet
. more correctly say, have issue spring context.
when application run via spring boot spring boot cares spring context , component scans.
if want run spring mvc application tomcat have configure spring application context manually either via xml or java base configuration. if don't want use web.xml
may use 'full java base' configuration webapplicationinitializer (you're using tomcat 7, supports servlet api 3.0)
by way, in way suggest create web.xml
run java web application in java web server tomcat.
please, loot in spring mvc documentation find more information.
Comments
Post a Comment