Recent learning

Keywords: Spring SQL SpringBoot Database

1.SpringBoot

What is SpringBoot

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".

We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.

There are too many configurations for Spring. What Spring boot does is to simplify the configuration. All the configurations you need to do before Spring boot helps you solve them. It is to hire a computer to help you write the configuration. All you need to do is to reach for your clothes and open your mouth. What you need is to import dependency into pom.
Before learning spring boot, you need to study the Spring Framework in depth.

2.SpringDate JPA

What is JPA?

Spring Data JPA, part of the larger Spring Data family, makes it easy to easily implement JPA based repositories. This module deals with enhanced support for JPA based data access layers. It makes it easier to build Spring-powered applications that use data access technologies.

Implementing a data access layer of an application has been cumbersome for quite a while. Too much boilerplate code has to be written to execute simple queries as well as perform pagination, and auditing. Spring Data JPA aims to significantly improve the implementation of data access layers by reducing the effort to the amount that's actually needed. As a developer you write your repository interfaces, including custom finder methods, and Spring will provide the implementation automatically.

JPA has written the sql statements once, and he has defined all the most basic sql statements for you. As long as they are not related to logical processing, they only need to define methods according to the agreed methods in the Dao interface, which can be automatically put into the Spring container and injected when using.
JPA can directly define the relationship between entities, and create or update the database tables based on these.
Of course, JPA also supports sql statement query and is defined in Dao interface. It also supports JQL syntax, which is more convenient.

3.Swagger

The Controller interface can be exposed directly, which can be used for front-end and back-end separation.
It can generate the same thing as the manual in production, with clear method function, parameters, return type, etc. it can also input data for testing, which is a very convenient tool.
The configuration is also very simple
First, add two dependencies

		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger2</artifactId>
			<version>2.6.1</version>
		</dependency>
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger-ui</artifactId>
			<version>2.6.1</version>
		</dependency>

Then create a configuration class Swagger2.java

@Configuration
@EnableSwagger2
public class Swagger2 {
	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
				.apis(RequestHandlerSelectors.basePackage("com.briup.web")).paths(PathSelectors.any()).build();
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder().title("swagger Study").description("describe").termsOfServiceUrl("http://www.cccccc.com")
				.version("1.0").build();
	}
}

Start the Boot project and visit http://localhost:8080/swagger-ui.html

4.git

END

Published 1 original article, praised 0, visited 6
Private letter follow

Posted by 244863 on Tue, 25 Feb 2020 23:51:06 -0800