installation steps
installation steps
It internally contains Groovy and Grape (JAR Dependency Manager) to add Spring Boot Defaults
and resolve all dependencies automatically.
We can install Spring Boot CLI software using either Windows Installer or Zip file. Both
approaches are easy to install and will give us same Spring Boot CLI software.
Step 1: You can download the Spring CLI distribution from the Spring software repository:
spring-boot-cli-1.4.0.BUILD-SNAPSHOT-bin.zip
spring-boot-cli-1.4.0.BUILD-SNAPSHOT-bin.tar.gz
Once downloaded, follow the INSTALL.txt instructions from the unpacked archive. In summary:
there is a spring script (spring.bat for Windows) in a bin/ directory in the .zip file, or
alternatively you can use java -jar with the .jar file (the script helps you to be sure that the
classpath is set correctly).
Step 3: Set Spring Boot CLI Environment Variables in Windows System as shown below.
1. set PATH= D:\personal data\doj\spring-1.4.0.BUILD-SNAPSHOT\bin
Step 4: Execute the below command to verify our installation process.
Using the CLI
Once you have installed the CLI you can run it by typing spring.
We can use “spring –version” to know the Spring Boot CLI Version as shown below.
1. C:\Users\Dinesh>spring --version
2. Spring CLI v1.4.0.BUILD-SNAPSHOT
We can use “spring –help” to know the Spring Boot CLI Version as shown below.
1. C:\Users\Dinesh>spring --help
2. usage: spring [--help][--version]
3. <command>[<args>]
4.
5. Available commands are:
6.
7. run [options]<files>[--][args]
8. Run a spring groovy script
9.
10. test [options]<files>[--][args]
11. Run a spring groovy script test
12. ……..more command help is shown here
Now our Spring Boot CLI Installation process is done successfully.
To pass command line arguments to the application, you need to use a -- to separate them
from the “spring” command arguments, e.g.
$ spring run app.java -- --server.port=9000
To set JVM command line arguments you can use the JAVA_OPTS environment variable, e.g.
$ JAVA_OPTS=-Xmx1024m spring run app.java
Observation on Code:
If we observe our app.java, we can find the following important points.
No imports
No other XML configuration to define Spring MVC Components like Views,ViewResolver
etc.
No web.xml and No DispatcherServlet declaration
No build scripts to create our Application war file
No need to build war file to deploy this application
Now our Spring Boot HelloWorld Example application is up and running. It’s time to test it now.
It is the responsibility of Spring Boot Core Components, Groovy Compiler (groovyc) and Groovy
Grape (Groovy’s JAR Dependency Manager).
Spring Boot Components uses Groovy Compiler and Groovy Grape to provide some Defaults
lime adding required imports, providing required configuration, resolving jar dependencies,
adding main() method etc. As a Spring Boot Developer, We don’t need to worry all these things.
Spring Boot Framework will take care of all these things for us.
Summary
The Spring Boot CLI takes the simplicity offered by Spring Boot auto-configuration and starter
dependencies and turns it up a notch. Using the elegance of the Groovy language, the CLI
makes it possible to develop Spring applications with minimal code noise.