官术网_书友最值得收藏!

Spring Boot CLI

Spring Boot also provides a command-line tool that can be used to quickly write Spring applications. You can run Groovy scripts with Spring Boot CLI. Groovy code has almost zero boilerplate code compared with Java.

The Spring Boot documentation says:

"You don't need to use the CLI to work with Spring Boot but it's definitely the quickest way to get a Spring application off the ground."

Spring Boot's CLI gives you more free time from having to add starter dependencies and auto-configuration to let you focus only on writing your application-specific code. We have seen this in this chapter in the Groovy script HelloController. We can run this Groovy script with Spring Boot CLI.

Spring Boot CLI is a smart tool, because in the Groovy script, if you noticed, there are no import lines. But, Spring Boot CLI allows us to run it. What about dependent libraries, you ask? We don't have Maven or Gradle here. CLI is smart; it detects classes being used in your application and it also knows which Starter dependencies should be used for these classes; accordingly, Spring Boot CLI adds dependencies to the classpath to make it work.

As Spring Boot CLI adds dependencies, a series of auto-configuration kicks in and adds the required bean method configuration so that your application is able to respond to HTTP requests.

CLI is an optional feature of Spring Boot; it just allows you to write a complete application with your application code only as, it doesn't need to build a traditional project. CLI provides tremendous power and simplicity for Spring development. In Chapter 2, Customizing Auto-Configuration in Spring Boot Application, we will see how to set up Spring Boot CLI.

Let's move to another key component of Spring Boot's building blocks. This is Spring Boot Actuator, which gives us insight about running a Spring Boot application.

主站蜘蛛池模板: 威海市| 富顺县| 广元市| 张家川| 乌拉特中旗| 确山县| 海城市| 东乡| 绍兴县| 江都市| 安图县| 芒康县| 西华县| 亚东县| 乐清市| 彰化县| 泉州市| 通道| 宁都县| 英吉沙县| 定安县| 阿图什市| 金坛市| 淮北市| 元朗区| 嘉鱼县| 千阳县| 武邑县| 二连浩特市| 浏阳市| 秭归县| 日土县| 定日县| 八宿县| 洛宁县| 江门市| 余江县| 五常市| 平阴县| 兖州市| 新干县|