the configurations of different environments. The configuration in the test environment overrides the development environment, and the configuration in the production environment overrides the test environment, so spring Boot provides a unified way to manage the configuration of the application, allowing developers to
1.Spring Boot
Project Download Address: https://download.csdn.net/download/weixin_39549656/10287664 1.1 What is spring Boot
advantages and disadvantages of 1.2.Spring boot
1.3. Quick Start 1.3.1. Setting the parent of
applied and installed into several different environments, such as: development, testing, production, etc. Each environment's database address, server port and so on configuration will be different, if you are packaging for different environments to frequently modify the configuration file, it will be a very cumbersome and prone to error.For a multi-environment configuration, the basic idea of a variety of project building tools or frameworks is consistent, and the
hard code, if the switch cache client also need to modify the code, high coupling, not easy to maintain Public string Get (String key) { = Usermapper.selectbyid (key); if NULL ) { cache.put (key,value); } return value;}After use:Based on spring cache annotations, the cache is configured by the developer itself, but does not involve a specific encoding@Cacheable (value = "User", key = "#key") public String get (string key) {
directly2.src/main/resources: Configuration directory, which is used to store some configuration information of the application, such as application name, service port, database configuration, etc. Since we have applied the Web module, we have created the static directory and the templates directory, which is used to store the resources, slices, CSS, JavaScript and so on, which is used to store the template file of the Web page.3.src/test: Unit
and Gradle is very strong. Its built-in ' Starter POM ' provides a highly encapsulated project build that maximizes the configuration of project builds. There are also plug-ins for maven and Gradle, which are packaged and run without the need to write extra scripts.Spring boot not only simplifies web applications, but also provides a range of dependencies to make other jobs out of the box. Several classic spring
1.Integration of timed tasks in spring bootIn the Startup class, add an annotation that opens a timed task:The use of timed tasks in Springboot is fairly straightforward. First, we add @enablescheduling to the startup class to open the timed task.@EnableScheduling Public class startapplication { publicstaticvoid main (string[] args) { Springapplication.run (startapplication. class , args);} }2. Then we directly create the se
Spring boot rest example
Introduction: This article will help you use Spring Boot to create simple REST services.
You will learn
What is a REST service?
How to Use Spring Initializr to guide the creation of Rest service applications?
How do I create a REST service to
in the Spring boot infrastructure with a total of three files (the exact path varies according to the group all the differences that the user fills in when the project is generated):
src/main/javaUnder the program entry:Chapter1Application
src/main/resourcesThe following configuration file:application.properties
src/test/
Gradle
Unlike Maven, Gradle does not provide a corresponding parent project to share the configuration, only by introducing the relevant "starter POMs" dependency. The Spring-boot-gradle-plugin is used to package the project as an executable file, and the dependent dependencies are given to Spring boot for management
through the CLI:Spring init-dweb,data-jpa,h2,thymeleaf--build Gradle readinglist The init command of the CLI cannot specify the project root package name and project name. The package name is demo by default and the project name is demo by default.2. Directory structureRegardless of the way we create a project, after importing the project into the IDE, we can see that the entire project structure follows the layout of a traditional Maven or Gradle project, where the main application code is lo
name
Description
Spring-boot-starter
Core POM, which includes automatic configuration support, a log library, and support for YAML configuration files.
Spring-boot-starter-amqp
Support AMQP via Spring-rabbit.
Spring Java Configuration 1, creating a MAVEN projectCreate a MAVEN project using idea, by the way, idea is really better than eclipse and familiar. Then MAVEN is the most mainstream of Java project management tools, first configure a try, very good to get started.2. Import DependencyEdit Pom File1, first configure the JDK version and code, two ways, according to any one of the reasons can be, out of the question if both of them, as follows2, import d
Generally in a project, there will always be a lot of environments. Like what:
Production environment, pre-release environment, test environment, development environment
The configuration files on each environment are always different, and even the environment of each developer in the development environment may be a little differently, and configuring reading is a bit of a headache.Spring Boot
spring.boot.admin.username registered to the Admin server's account Spring.boot.adm In.password registration to Admin server password spring.boot.admin.period default 10.000 retry registration interval spring.boot.admin.auto-registration default True Automatically perform recurring registration tasks after the app starts spring.boot.admin.auto-deregistration default False when the app is closed, automatically unregister Spring.boot.admin.client.health-url Spring.boot.admin.client.management-url
/main/java: Main program Entry springbootdemoapplication, you can start the Spring boot app by running the class directly
Src/main/resources: Configuration directory, which is used to store some configuration information of the application, such as application name, service port, database configuration, etc. Since we have applied the Web module, we have created the static directory and the templates dir
Spring Boot creates beans using Java code and registers them to Spring.
From Spring3.0, a new method is added to configure Bean Definition, which is to configure Bean Definition through Java Code.The two configuration methods differ from Xml and Annotation:
The first two Xml and Annotation configuration methods are pre-defined, that is, after developers use the X
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.