[JAVA] Beginning with Spring Boot 0. Use Spring CLI


I decided to use Spring (Framework) at work I decided to touch Spring Boot, which I had been interested in for a long time. By the way, Spring Boot ≠ Spring Framework, but I dare to select Spring Boot in private.

This time, try using Spring CLI before Spring Boot.


software version
OS Windows10 Pro
Java OpneJDK 12.0.2
Spring CLI v2.3.5.RELEASE


1. Drop the Spring CLI.

Official introductory document (Japanese) Drop the spring-boot-cli-2.3.5.RELEASE-bin.zip and unzip it. Pass the spring-2.3.5.RELEASE \ bin folder under the unzipped folder to the path.

Now you can use the spring command. Execute the following command as a trial, and if the version is returned, the installation is successful.

Version confirmation command

spring version

Execution result

C:\>spring version
Spring CLI v2.3.5.RELEASE

2. Code implementation for REST API

Write code for the REST API because it can be anywhere on your PC. The official introductory documentation is written in Groovy, but Java is fine too.


public class Test {

    public String home() {
    	return "Hello World!";

    public String helloSb() {
        return "Hello SpringBoot!";



class ThisWillActuallyRun {

    String home() {
        "Hello World!"

    String helloSb() {
        "Hello SpringBoot!"


By the way, if it is the above level, the import statement is unnecessary. (If you do it in the IDE, a compile error will be displayed)

3. Run

Execute the following command in the place where the source code for REST API is located.

spring run app.java

Then, the following message is displayed and the REST API application is started. It seems that the necessary libraries are automatically downloaded.

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

2020-11-15 12:31:05.416  INFO 9532 --- [       runner-0] o.s.boot.SpringApplication               : Starting application on XXXXXXXXXX(Machine name) with PID 9532 (started by xxxx in M:\develop\works\Spring\20201115_springboot_start)
2020-11-15 12:31:05.421  INFO 9532 --- [       runner-0] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (jar:file:/M:/develop/tools/Spring/spring-boot-cli-2.3.5.RELEASE-bin/spring-2.3.5.RELEASE/lib/spring-boot-cli-2.3.5.RELEASE.jar!/BOOT-INF/lib/groovy-2.5.13.jar!/) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-11-15 12:31:06.384  INFO 9532 --- [       runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-11-15 12:31:06.394  INFO 9532 --- [       runner-0] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-11-15 12:31:06.394  INFO 9532 --- [       runner-0] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.39]
2020-11-15 12:31:06.426  INFO 9532 --- [       runner-0] org.apache.catalina.loader.WebappLoader  : Unknown class loader [org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader@6adca536] of class [class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader]
2020-11-15 12:31:06.458  INFO 9532 --- [       runner-0] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-11-15 12:31:06.458  INFO 9532 --- [       runner-0] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 889 ms
2020-11-15 12:31:06.601  INFO 9532 --- [       runner-0] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-11-15 12:31:06.879  INFO 9532 --- [       runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-11-15 12:31:06.887  INFO 9532 --- [       runner-0] o.s.boot.SpringApplication               : Started application in 1.795 seconds (JVM running for 3.034)

4. Operation check

Try accessing the following.

http://localhost:8080/ image.png

http://localhost:8080/sb image.png

Oh ~ good ~: grinning:


The REST API has been created with haste only with the Spring CLI. (It just returns a string) You don't even need an IDE at this point. This may be fine if you want to make a really simple API mock.

Is Spring Boot proper next time? I want to make an application.


Official introductory document (Japanese)

Recommended Posts

Beginning with Spring Boot 0. Use Spring CLI
Use Spring JDBC with Spring Boot
Use Basic Authentication with Spring Boot
Use cache with EhCashe 2.x with Spring Boot
Learning Spring Boot [Beginning]
Download with Spring Boot
How to use MyBatis2 (iBatis) with Spring Boot 1.4 (Spring 4)
How to use built-in h2db with spring boot
Generate barcode with Spring Boot
Hello World with Spring Boot
Implement GraphQL with Spring Boot
Get started with Spring boot
Hello World with Spring Boot!
File upload with Spring Boot
Spring Boot starting with copy
Spring Boot starting with Docker
Hello World with Spring Boot
Set cookies with Spring Boot
Add module with Spring Boot
Getting Started with Spring Boot
Create microservices with Spring Boot
Send email with spring boot
File upload with Spring Boot (do not use Multipart File)
gRPC on Spring Boot with grpc-spring-boot-starter
Create an app with Spring Boot 2
Hot deploy with Spring Boot development
Database linkage with doma2 (Spring boot)
Spring Boot programming with VS Code
Until "Hello World" with Spring Boot
Inquiry application creation with Spring Boot
Get validation results with Spring Boot
(Intellij) Hello World with Spring Boot
Create an app with Spring Boot
Google Cloud Platform with Spring Boot 2.0.0
Use DBUnit for Spring Boot test
Check date correlation with Spring Boot
How to use ModelMapper (Spring boot)
I tried GraphQL with Spring Boot
[Java] LINE integration with Spring Boot
Use thymeleaf3 with parent without specifying spring-boot-starter-parent in Spring Boot
I tried Flyway with Spring Boot
Message cooperation started with Spring Boot
Spring Boot gradle build with Docker
Hello World with Eclipse + Spring Boot + Maven
Send regular notifications with LineNotify + Spring Boot
HTTPS with Spring Boot and Let's Encrypt
Try using Spring Boot with VS Code
Start web application development with Spring Boot
Launch Nginx + Spring Boot application with docker-compose
Use DynamoDB query method in Spring Boot
I tried Lazy Initialization with Spring Boot 2.2.0
Implement CRUD with Spring Boot + Thymeleaf + MySQL
Implement paging function with Spring Boot + Thymeleaf
(IntelliJ + gradle) Hello World with Spring Boot
Form class validation test with Spring Boot
Run WEB application with Spring Boot + Thymeleaf
Achieve BASIC authentication with Spring Boot + Spring Security
Challenge Spring Boot
Spring Boot Form
Spring Boot Memorandum
gae + spring boot