jueves, 15 de marzo de 2018

Spring Boot CLI instalación test con Groovy


Spring Boot CLI es la versión command line de spring boot, la forma de instalarlo es bajando el CLI de




una vez descargado y descomprimido desde el directorio asignamos las variable de ambiente JAVA_HOME, debe ser 1.8+

C:\Users\Bext\Downloads\spring-2.0.0.RELEASE\bin>SET JAVA_HOME=C:\Program Files\Java\jdk1.8.0_112

Verificamos su instalación

C:\Users\Bext\Downloads\spring-2.0.0.RELEASE\bin>spring --version
Spring CLI v2.0.0.RELEASE

C:\Users\Bext\Downloads\spring-2.0.0.RELEASE\bin>spring
usage: spring [--help] [--version]
       <command> [<args>]

Available commands are:

  run [options] <files> [--] [args]
    Run a spring groovy script

  grab
    Download a spring groovy script's dependencies to ./repository

  jar [options] <jar-name> <files>
    Create a self-contained executable jar file from a Spring Groovy script

  war [options] <war-name> <files>
    Create a self-contained executable war file from a Spring Groovy script

  install [options] <coordinates>
    Install dependencies to the lib/ext directory

  uninstall [options] <coordinates>
    Uninstall dependencies from the lib/ext directory

  init [options] [location]
    Initialize a new project using Spring Initializr (start.spring.io)

  encodepassword [options] <password to encode>
    Encode a password for use with Spring Security

  shell
    Start a nested shell

Common options:

  -d, --debug Verbose mode
    Print additional status information for the command you are running


See 'spring help <command>' for more information on a specific command.


creamos un archivo en Groovy script, que utilizara Spring MVC Rest

archivo app.groovy

@RestController
class AppCtrl {

    @RequestMapping("/")
    String app() {
        "Corriendo Spring boot desde CLI, app.groovy :)"
    }
}

Lo ejecutamos con spring boot CLI, en este caso desde el puerto 9000

C:\Users\Bext\Downloads\spring-2.0.0.RELEASE\bin>spring run app.groovy -- --server.port=9000

Resolving dependencies..

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.0.RELEASE)

2018-03-15 18:39:57.523  INFO 9632 --- [       runner-0] o.s.boot.SpringApplication               : Starting application on android-ae23f0022eea with PID 9632 (started by Bext in C:\Users\Bext\Downloads\spring-2.0.0.RELEASE\bin)
2018-03-15 18:39:57.543  INFO 9632 --- [       runner-0] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2018-03-15 18:39:58.166  INFO 9632 --- [       runner-0] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@f6d5c84: startup date [Thu Mar 15 18:39:58 CST 2018]; root of context hierarchy
2018-03-15 18:40:02.540  INFO 9632 --- [       runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9000 (http)
2018-03-15 18:40:02.629  INFO 9632 --- [       runner-0] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-03-15 18:40:02.630  INFO 9632 --- [       runner-0] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.28
2018-03-15 18:40:02.667  INFO 9632 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_112\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Python34\Lib\site-packages\PyQt4;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\apache-maven-3.5.0\bin;C:\Program Files\Java\jdk1.7.0_79\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Git Cola\bin;C:\Program Files\nodejs\;C:\Program Files\MongoDB\Server\3.4\bin;%appdata%\npm;C:\Program Files\nodejs;C:\Program Files (x86)\Yarn\bin;C:\Program Files (x86)\Brackets\command;C:\Program Files\Heroku\bin;C:\Program Files\Docker Toolbox;C:\Users\Bext\AppData\Local\Yarn\bin;.]
2018-03-15 18:40:02.839  INFO 9632 --- [ost-startStop-1] org.apache.catalina.loader.WebappLoader  : Unknown loader org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader@75890717 class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2018-03-15 18:40:02.994  INFO 9632 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-03-15 18:40:02.995  INFO 9632 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4838 ms
2018-03-15 18:40:03.667  INFO 9632 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-03-15 18:40:03.689  INFO 9632 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-03-15 18:40:03.692  INFO 9632 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-03-15 18:40:03.694  INFO 9632 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-03-15 18:40:03.696  INFO 9632 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-03-15 18:40:05.161  INFO 9632 --- [       runner-0] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@f6d5c84: startup date [Thu Mar 15 18:39:58 CST 2018]; root of context hierarchy
2018-03-15 18:40:05.478  INFO 9632 --- [       runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String AppCtrl.app()
2018-03-15 18:40:05.501  INFO 9632 --- [       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-03-15 18:40:05.507  INFO 9632 --- [       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-03-15 18:40:05.702  INFO 9632 --- [       runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-15 18:40:05.704  INFO 9632 --- [       runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-15 18:40:05.887  INFO 9632 --- [       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-03-15 18:40:07.301  INFO 9632 --- [       runner-0] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-03-15 18:40:07.458  INFO 9632 --- [       runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9000 (http) with context path ''
2018-03-15 18:40:07.468  INFO 9632 --- [       runner-0] o.s.boot.SpringApplication               : Started application in 11.757 seconds (JVM running for 18.908)

abrimos el browser para ver el resultado


fin texto

No hay comentarios:

Publicar un comentario