"Spring Boot combat" reading and finishing

"Spring Boot in Action" (1st Edition) published by Manning Publishing House Craig Walls (author) / Ding Xuefeng (translator)
Manning Homepage: https://www.manning.com

Spring Boot Homepage: https://projects.spring.io /spring-boot/
V1.5.2 online documentation: http://docs.spring.io/spring-boot/docs/1.5.2.RELEASE/reference/htmlsingle/
GitHub: https://github.com/spring- projects/spring-boot

---------------------------------------------- ----------------------------
The following is my own book review
This book is the latest book by Craig Walls, author of the bestselling "Spring in Action" .
To learn a new technology, in addition to getting started with Hello World at the fastest speed, you should also understand its background, main uses and so on. Essentially, Spring Boot is Spring, and its purpose is to simplify Spring development. Throughout the history of human civilization, it is actually the welfare of lazy people who do not want to wash clothes, so there are washing machines, from semi-automatic to fully automatic to drying and washing. I don't want to sweep the floor, so I have a vacuum cleaner, from wired to handheld wireless to sweeping robots. For Java developers, no one knows about Spring. When I first entered the industry, Spring was only v2.5, and now the snapshots of Srping v5.0 are out. It is precisely because of the unremitting efforts of the Spring development team that we can liberate our "hands" and make our code more concise and easy to maintain.
This book is mainly aimed at getting started with Spring Boot. There are many ways to get started quickly. The documentation on blog, github, or the official website is a good place to learn. But what I want to say is that it took me a day to read "Spring Boot Combat", and then I have a systematic understanding of this framework, which is still very cost-effective! Of course, if you want to learn more about Spring Boot, you have to start from other ways.

-------------------------------------------------- -----------------------
Book Contents:
  • Chapter 1, Getting Started
  • Chapter 2, Developing Your First Application
  • Chapter 3, Custom Configuration
  • Chapter 4, Testing
  • Chapter 5, Groovy and the Spring Boot CLI
  • Chapter 6, Using Grails with Spring Boot
  • Chapter 7, In-depth Actuator
  • Chapter 8, Deploying Spring Boot Applications
  • Appendix A, Spring Boot Developer Tools
  • Appendix B, Spring Boot Startup Dependencies
  • Appendix C, Configuration Properties
  • Appendix D, Spring Boot dependencies

-------------------------------------------------- -------------
The following is the book excerpt:

【Translator's order】
Spring Boot brings a better development experience for developers, but after writing Code is only a small step on the long journey of thousands of miles, and the follow-up operation and maintenance work is what makes many people truly moved and helpless. Spring Boot has done a lot of work in operation and maintenance. Deployment, monitoring, and measurement are all within its scope. Combined with Spring Cloud, services such as service discovery and service degradation can be easily implemented.

[Preface]
Spring Boot is the kind of framework that the Java community has been exploring for more than ten years. Its easy-to-use development features and out-of-the-box operation and maintenance capabilities make Java development fun again.

[Foreword]
It seems that every Spring application takes the developer's life to the next level, which can only be seen from the way Spring's components are declared and woven. Let's take a look at some evolutions in Spring's history.
  • The advent of Spring 1.0 has revolutionized the way we develop enterprise Java applications. Spring's dependency injection and declarative transactions mean that there is no more tight coupling between components and no more heavyweight EJBs. This thing couldn't be better.
  • With Spring 2.0, we may use a custom XML namespace in the configuration, and the smaller, easier-to-understand configuration file makes Spring itself easier to use. This thing couldn't be better.
  • Spring 2.5 gives us a more elegant annotation-oriented dependency injection model (ie @Conponent and @Autowired annotations), and an annotation-oriented Srping MVC programming model. There is no need to explicitly declare application components, nor to inherit from a basic control class. This thing couldn't be better.
  • With Spring 3.0, we have a new set of Java-based configurations that can replace XML. In Spring 3.1, a series of annotations starting with @Enable further complete this feature. Finally, for the first time, we can write a Spring application without any XML configuration. This thing couldn't be better.
  • Spring 4.0 provides support for conditional configuration. Depending on the application's Classpath, environment, and other factors, runtime decisions will decide which configurations to use and which to ignore. Those decisions no longer need to be scripted at build time; it used to put the chosen configuration in the deployed package, which is no longer the case. This thing couldn't be better.

When we think something can't be better, it's bound to get better. Advances in Spring Boot are bringing more and more benefits. It's really hard to imagine that Srping could get better, but it's definitely better. There is no doubt that Spring's future is always bright.

[Chapter 1] Getting Started with the
Four Cores of Spring Boot: Automatic Configuration, Startup Dependencies, Command Line Interface, and Actuator.

Spring Boot does not introduce any open code generation, but instead leverages the conditional configuration features of Spring 4 and the transitive dependency resolution provided by Maven and Gradle to achieve automatic configuration in the context of Spring applications.

Fundamentally, Spring Boot projects are just ordinary Spring projects, but they just use Spring Boot's starting dependencies and auto-configuration.


Spring Boot CLI installation.

[Chapter 2] Developing the first application
@SpringBootApplication enables Spring's component scanning and Spring Boot's auto-configuration capabilities.

Spring Boot reduces the complexity of project dependencies by providing numerous starter dependencies. A starter dependency is essentially a Maven Project Object Model (POM) that defines transitive dependencies on other libraries that together support a feature. (usually in the form of spring-boot-start-*).

Spring Boot dependencies do not need to specify a version.
You're somewhat uneasy about not knowing which version of your dependencies you're using. You need to be confident that Spring Boot has been tested enough to ensure that all dependencies introduced are compatible with each other. It's a relief to just specify the starting dependencies and not worry about which libraries you need to maintain or their versions. (Of course, there are still many ways to really want to see, such as mvn dependency command or through Spring Boot actuator endpoint).

Spring Boot's auto-configuration is a run-time (more precisely, application startup) process, and many factors are considered before deciding which Spring configuration should be used and which should not be used. (In fact, it is a decision-making process).
Every time an application starts up, Spring Boot's auto-configuration makes nearly 200 decisions, covering security, integration, persistence, web development, and more. All this automatic configuration is to try not to let you write the configuration yourself.

Automatic configuration related JAR: spring-boot-autoconfigure.

All of these configurations are so different because they take advantage of Spring's conditional configuration, a new feature introduced in Spring 4.0. Conditional configuration allows a configuration to exist in an application, but ignore that configuration until some specific condition is met.

[Chapter 3] Custom Configuration
Spring Boot is designed to load application-level configuration first, and then consider auto-configuration classes.

How application.properties\application.yml

uses custom configuration.
Spring Boot's property parser is smart enough to automatically associate camel-cased properties with properties of the same name that use hyphens or underscores.

Default error page: error.*
Default resource: src/main/resources/static or src/main/resources/public

[Chapter 4] Testing
SpringJunit4ClassRunner

Spring: @ContextConfigureation: specifies how to load the application context.
Spring Boot: @SpringApplicationConfiguration: Loads the Spring application context, including loading external properties and Spring Boot logs.

Spring Mock MVC framework. (Since Spring v3.2)

HTML Application Testing: Selenium (www.seleniumhq.org)

[Chapter 5] Groovy and Spring Boot CLI
Command Line Tools Spring Boot CLI combines the power of Spring Boot and Groovy for Spring applications The program forms a set of simple and powerful development tools.

[Chapter 6] Using Grails with Spring Boot

[Chapter 7] In-depth Actuator
Spring Boot Actuator provides many production-grade features, such as monitoring and measuring Spring Boot applications. These features of Actouator are available in a number of ways such as REST endpoints, remote shells and JMX.

Endpoints list:
official website can be found: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready

endpoint example
View configuration details: /beans, /autoconfig, /evn , /mappings
runtime metrics: /metrics, /trace, /dump, /health
Shutdown application: /shutdown
Get application information: /info

Customize Actuator
1. Modify endpoint ID
2. Enable and disable endpoint
3. Add custom metrics information (such as custom /metrics, specify how many times method X was called, the last time it was called time).
4. Create a custom trace warehouse (such as custom /trace, expand the default 100 traces to x, or save trace data in MongoDB, etc.).
5. Insert a custom health indicator (custom/health).

Securing Actuator: Securing endpoints with Spring Security:
1. Define all endpoints with a fixed prefix.
2. Use wildcards in Security to secure endpoints.

[Chapter 8] Deploying Spring Boot Applications
Spring Boot applications can be packaged in a number of ways:
Deploy the product production methods target environment
Groovy source code handwriting Cloud Foundary and container deployment, such as Docker
executable JAR Maven、Gradle或Spring Boot CLI Cloud environments, including Cloud Foundary and Heroku, and container deployments such as Docker
WAR Maven or Gradle Java application server or cloud environment such as Cloud Foudary


Build the WAR file
SpringBootServletInitialiar#configure(SpringApplicationBuilder builder)

>mvm package The
servlet context path will be the same as the main filename of the WAR file.

-------------------------------------------------- -------------
Some technologies mentioned in this book:

Groovy language
Build tools: Maven, Gradle

Spring in Action (4th Edition)

Spring Tool Suite is a distribution of the Eclipse IDE that adds many features to aid Spring development.

Defining Web Views with Thymeleaf

Spring Data JPA \ Spring Data MongoDB
Spring Security

Spring Boot's default log: LogBack ( http://logback.qos.ch )

Grails is an open source framework for rapid web application development based on the Groovy programming language , and built on open source frameworks such as Spring and Hibernate, it is a high productivity one-stop framework.

Two popular database migration libraries:
Flyway ( http://flywaydb.org )
Liquibase( http://www.liquibase.org

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326483118&siteId=291194637