Create
HelloWorld.groovy file with below content.
HelloWorld.groovy
@RestController class HelloWorld { @RequestMapping("/") String home() { "Hello World!" } }
Execute
the command ‘spring run HelloWorld.groovy’.
It
starts the embedded tomcat server and deploy HelloWorld application.
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.1.RELEASE) 2018-04-20 13:27:36.397 INFO 17248 --- [ runner-0] o.s.boot.SpringApplication : Starting application on INLN50911363A with PID 17248 (started by krishna in C:\Users\krishna\Documents\Study\Spring Boot\examples) 2018-04-20 13:27:36.409 INFO 17248 --- [ runner-0] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default 2018-04-20 13:27:36.694 INFO 17248 --- [ runner-0] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@8382c0f: startup date [Fri Apr 20 13:27:36 IST 2018]; root of context hierarchy 2018-04-20 13:27:38.779 INFO 17248 --- [ runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2018-04-20 13:27:38.816 INFO 17248 --- [ runner-0] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-04-20 13:27:38.817 INFO 17248 --- [ runner-0] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.29 2018-04-20 13:27:38.908 INFO 17248 --- [ost-startStop-1] org.apache.catalina.loader.WebappLoader : Unknown loader org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader@3ab33fdd class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader 2018-04-20 13:27:38.974 INFO 17248 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-04-20 13:27:38.974 INFO 17248 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2284 ms 2018-04-20 13:27:39.219 INFO 17248 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/] 2018-04-20 13:27:39.228 INFO 17248 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-04-20 13:27:39.229 INFO 17248 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-04-20 13:27:39.231 INFO 17248 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-04-20 13:27:39.232 INFO 17248 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-04-20 13:27:39.450 INFO 17248 --- [ runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2018-04-20 13:27:39.822 INFO 17248 --- [ runner-0] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@8382c0f: startup date [Fri Apr 20 13:27:36 IST 2018]; root of context hierarchy 2018-04-20 13:27:39.931 INFO 17248 --- [ runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String HelloWorld.home() 2018-04-20 13:27:39.940 INFO 17248 --- [ runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2018-04-20 13:27:39.943 INFO 17248 --- [ runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 2018-04-20 13:27:39.999 INFO 17248 --- [ runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2018-04-20 13:27:40.002 INFO 17248 --- [ runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2018-04-20 13:27:40.531 INFO 17248 --- [ runner-0] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2018-04-20 13:27:40.601 INFO 17248 --- [ runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2018-04-20 13:27:40.609 INFO 17248 --- [ runner-0] o.s.boot.SpringApplication : Started application in 5.284 seconds (JVM running for 8.153)
Open
browser hit the url ‘http://localhost:8080/’ in browser, you can
able to see ‘Hello World!’ message.
No comments:
Post a Comment