Spring Boot boot process
The Spring Boot series-5 minutes to build an app-explains how to quickly create a spring boot project and run it. Although the steps are simple and the develope
see the monitoring information for a particular example.Sample codeEmail alertsSpring Boot Admin Shows all the application information in the micro-service in the background, so it is very convenient for us to monitor and govern the micro-service overall. But our operators are not able to stare at the background 24 hours a day, so if the service is abnormal, there is a corresponding message alarm is too good, in fact,
://image.uc.cn//s/wemedia/s/upload/2017/ 53a906b18e4073aec300ce79f084d340x1246x631x25.png "alt=" 53a906b18e4073aec300ce79f084d340x1246x63 "/>DescriptionThe 1 indicates:When the user name, password exists, from the session to get the user really need to go to the page, and then through the redirect to the corresponding pageThe 2 indicates:The login page that jumps directly when the user is not logged in.To run the project:The direct access hijsp path is not logged in and is redirected to the logi
add the message Converter's @bean to the spring container in the @configuration class, and it will be automatically added to the container by spring boot.code example:
@Bean public Stringhttpmessageconverter Stringhttpmessageconverter () { stringhttpmessageconverter converter = new Stringhttpmessageconverter ( charset.forname ("UTF-8
://image.uc.cn//o/wemedia/s/upload/2017/ 2ff5df82a80104a8e9c46476bcdd3332x996x519x15.png;,3,jpegx;3,700x.jpg "alt=" 2ff5df82a80104a8e9c46476bcdd3332x996x519 "/>So what if we want to define ourselves?Remember the global configuration you learned before?650) this.width=650; "Src=" http://image.uc.cn//o/wemedia/s/upload/2017/ 21f59b3361cbc0ea507f04c380e78a31x510x98x4.png;,3,jpegx;3,700x.jpg "alt=" 21f59b3361cbc0ea507f04c380e78a31x510x98x "/>In the global configuration file, we can customize the pre
-service is suitable, single jar package deployment and management are very convenient. As long as the system architecture design is reasonable, large-scale projects can be used, coupled with nginx load balancing, easy to achieve horizontal expansion;spring bootTo solve the problem, thin provisioning is on the one hand, and on the other hand how to easily spring integrate the ecosystem and other toolchain (
framework
Jsonassert: A library of assertions for JSON
Jsonpath:json XPath Library
We only need to introduce the dependency package into the project spring-boot-start-test , we can test the database, Mock, the Web and so on.Spring Boot test contains a variety of test scenarios that we need to use to meet the testing needs of our daily projects.Sprin
1th Chapter Series OverviewOverview of the overall agenda of the spring Boot 2.0 in-depth practice series, including the spring boot three core features (assembly automation, embedded WEB containers, production readiness features), Web applications (traditional Servlet, Spring
framework
Jsonassert: A library of assertions for JSON
Jsonpath:json XPath Library
We only need to introduce the dependency package into the project spring-boot-start-test , we can test the database, Mock, the Web and so on.Spring Boot test contains a variety of test scenarios that we need to use to meet the testing needs of our daily projects.Sprin
annotation, is to identify a control, Rescontroller is the collective of @controller and @responsebody.The role of Responsebody again: @responsebody means that the return result of the method is written directly to the HTTP response body. Typically used when retrieving data asynchronously, after using @requestmapping, the return valueusually resolves to the jump path, plus @responsebody after the return result will not be resolved to the jump path, but directly written to the HTTP response body
)
Execution java -jar xxx.jar --spring.profiles.active=prod , you can observe that the service port is set to 3333 , that is, the configuration of the production environment (PROD)
According to the above experiment, we can summarize the multi-environment configuration ideas as follows:
application.propertiesThe common content is configured in and set to the spring.profiles.active=dev development environment as the default configuration
application-{profile}.properti
picture description650) this.width=650; "src=" Http://www.kaigejava.com/res/plugins/ueditor/themes/default/images/spacer.gif "alt=" Spacer.gif "/>Explanation of @EnableAutoConfiguration notes:View source code and notes for this note:650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ Bb26c88b847889617d74d3592170178dx1863x781x58.png "alt=" bb26c88b847889617d74d3592170178dx1863x78 "/>Please click here to enter the picture description650) this.width=650; "src=" Http://www.kaig
Spring Boot series (iii) Spring boot common annotations
@RestController and @requestmapping
@RestController is called a stereotype (stereotype) annotation. It provides suggestions for developers who read the code. For spring, this class plays a special role. It inherits fro
object and use the @bean callout as the spring bean
Here's an example that returns the Graphqlschema object directly in a simplified manner as follows:
@Bean
Graphqlschema schema () {
String schema = "type Query {hello:string}";
Schemaparser schemaparser = new Schemaparser ();
Typedefinitionregistry typedefinitionregistry = schemaparser.parse (schema);
Runtimewirin
framework
Jsonassert: A library of assertions for JSON
Jsonpath:json XPath Library
We only need to introduce the dependency package into the project spring-boot-start-test , we can test the database, Mock, the Web and so on.Spring Boot test contains a variety of test scenarios that we need to use to meet the testing needs of our daily projects.Sprin
.
@ EnableAutoConfigurationWith @ Import (EnableAutoConfigurationImportSelector. class), The META-INF/spring. factories will be scannedAll org. springframework. boot. autoconfigure. EnableAutoConfiguration. For further scanning.
Complete.
mvn clean install
Create a new project. Introduce the package project
@Autowired private StringRedisTemplate redisTemplate;
That's easy.
Most of the time we want to expan
load into the Pom.xml properties> project.build.sourceEncoding>UTF-8project.build.sourceEncoding> java.version>1.8java.version> properties>A city standard spring boot code structureA typical spring boot project structure, which is also recommended by the websitecom +-
1th Chapter Series OverviewOverview of the overall agenda of the spring Boot 2.0 in-depth practice series, including the spring boot three core features (assembly automation, embedded Web capacity, production readiness features), Web applications (traditional Servlet, Spring
This section will delve into the details of spring boot to learn the main features of the spring boot that you want to use or customize.1. SpringapplicationThe Springapplication class provides a convenient way to guide a spring application, which is opened from the main meth
Configuration is one of the key cores of the spring framework, so the spring application will certainly need to be configured to run normally, but the use of spring Boot after a lot of configuration is not done, then auto-configuration exactly how it happened? What is the order and procedure of the occurrence? How did
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.