Moment For Technology

First introduction to Spring Cloud series - Spring Boot 01

Posted on Aug. 9, 2023, 5:26 a.m. by William Mortimer
Category: The back-end Tag: The back-end Spring Cloud

This is the first day of my participation in Gwen Challenge. Please check out Gwen Challenge for details

What is Spring Boot?

When we were young, we always learned something by its appearance, and then memorized it over and over again to know what it was. So what does Spring Boot look like?

Spring Boot features?

  • Create stand-alone Spring applications

  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)

  • Provide opinionated 'starter' dependencies to simplify your build configuration

  • Automatically configure Spring and 3rd party libraries whenever possible

  • Provide production-ready features such as metrics, health checks, and externalized configuration

  • Absolutely no code generation and no requirement for XML configuration

To put it simply: Spring Boot makes it easy to create stand-alone, production-grade, Spring-based applications that run directly.

Spring Boot related notes

  • Bean declaration
    • @Component: for base layer generic components
    • @service: for the business logic layer
    • Controller: Used for presentation layer
    • @repository: for the data access layer
  • Bean injection
    • @autoWired: Service dependency injection, used to inject components defined by @Component and @Service
    • @Resource: Component injected into @Repository definition
  • The configuration class
    • @Configuration: Declares this class to be a Configuration class that replaces an XML Configuration file and contains one or more @Bean annotation methods inside the annotated class.
    • @bean: Declares that the return value of this method is the Bean instance
    • @ComponentScan: Configures Component scanning
  • Spring MVC annotations
    • RestController: combine annotations for @Controller and @responseBody
    • @requestMapping: Specifies the access path and parameters
    • RequestBody: allows the Request parameters to be in the RequestBody
    • @pathvariable: Accepts path-based parameters
    • @ExceptionHandler: Exception processing of the global controller
  • .

How to build Spring Boot?

  1. Create online: start.spring. IO /
  2. Development tool creation


ArtifactId: artifactId is usually the project name or module name.

GroupId: groupId is divided into several fields, such as The com in front of it is [domain], and the domain name behind it is created by itself.

In the created project, we mainly used Java, Resources and test files when writing code. If we want to import new dependencies, we can add corresponding dependencies in the POM. XML file, as follows

Copy the code
About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.