ObjectiveThis essay will make a simple filing of the common annotations in Spring boot, and the order of writing will start from the start-up class and be extended to both inside and outside, for the purpose of sharing and for the convenience of future review and inspection.1. ApplicationThe Startup class example is as follows:@SpringBootApplicationpublicclass Ap
initialization of the Redis jar environment.Third, configure how to manage issues uniformlyA component (Jar package) comes out, the configuration will be more, such as the project involves Kafka configuration, thread pool configuration and so a lot of, the traditional way is to write a related document, a bunch of configuration items will make it very cumbersome to use.1, the Convention is better than the configurationIn spring Cloud/
1.Adding the Maven DependencyAs mentioned above, we'll use the Springfox implementation of the Swagger specification. To add it to my Maven project, we need a dependency in the Pom.xml file.
Io.springfox
Springfox-swagger2
2.7.0
2.Integrating Swagger 2 into the Project
2.1.Java Configuration The configuration of Swagger mainly centers around the docket Bean.
Swagger 2 is enabled through the@EnableSwagger2Annotation. After the docket bean was defined, itsSelect ()method return
requesting/css/index.css, Spring MVC is found under the/static/directory.If configured as/static/js/index.jsscript src="${request.contextPath}/static/js/index.js">script>There are no/static directories under the directories configured above, so resource files cannot be found.At this point, you need to add a custom mapping:registry.addResourceHandler("/static/**") .addResourceLocations("classpath:/static/")
So, when we use the S
Logs, usually not presented separately as a function in the requirements phase, or in the details of the product scenario. However, this does not affect its important position in any system at all.
In order to ensure that the service is highly available, the problem must be solved even, the problem must be rapid, so the production environment once the problem, the early warning system through the mail, text messages and even the way the phone to implement multidimensional bombing mode, to ensure
AOP is the abbreviation of Aspect oriented programming, which means: face-cutting programming, through the pre-compilation method and run-time dynamic agent implementation of the unified maintenance of the program functions of a technology. AOP is an important part of the spring framework by defining an entry point for an existing program and then cutting into different executions before and after it, such as: Opening a database connection/closing a d
cross-domain access support (Spring Boot, Nginx, browser)
What is cross-domain.
Cross-domain refers to the browser's inability to execute scripts for other Web sites. It is caused by the browser's homologous policy and is the security restrictions imposed by the browser.
This article turns from: Public number (a Li Springcloud) one, Spring
This article uses the spring Boot using the example Introduction, using JDBC template how to manipulate the memory database and MySQL database.
First, Spring boot uses the JDBC template to manipulate the memory database (H2)
First create a basic
and changing will we need business. For example, one of the following methods of inserting data adds a transaction:
@Override
@Transactional (propagation = Propagation.required,isolation = isolation.default,timeout=36000, Rollbackfor=exception.class) Public
Integer Add (Cbf_jtcy t) {return
Cbf_jtcymapper.insert (t);
}
If you do not know what is inside, you can view this article, Spring,mybatis Transac
instead of tomcat-embed, so check the official documentation as follows:The first step in producing a deployable war file was to provide a springbootservletinitializer subclass and override its C Onfigure method. Doing so makes use of the Spring Framework ' s Servlet 3.0 support and lets you configure your application when it's launched B Y the servlet container. Typically, you should update your application ' s main class to extend Springbootservlet
MethodValidationPostProcessor();}Then add annotations to the class method@Validated@RestController@RequestMapping("/spring-boot/classroom")@Validatedpublic class ClassroomController { ...}Annotations that are not in effect before, etc., are then @Range @Min @Max validator available in the package.(c) It is estimated that there will be people asking if the validator annotations in the package do not meet ou
Setenvironment is run when the system is started.Or, for example, the following controller:@Controllerpublicclass PageController implements EnvironmentAware{ @Override publicvoidsetEnvironment(Environment environment) { String s = environment.getProperty("JAVA_HOME"); System.out.println(s); }}We can also read the properties in the Application property configuration file via @configurationproperties. @Configuration @Conditiona
The company has recently split online services, naturally using the Spring family Hall-level micro-service Framework--spring boot, which discards the cumbersome XML configuration files in spring, and the declarative annotation approach provides a quick and concise way to configure service development. In
"
So when you enter "th:" In the code, you will see all the tags of Thymeleaf.Third, Spring Boot integrated THYMELEAF 3.1 development environment
Spring Boot 2.0.4
Thymeleaf 3.0.9
JDK 8
Windows 10
Idea 2018.2
Before formally integrating the Thymeleaf engine, consider the directory structure3
see that the same function is implemented through the interceptor. However, it is worth noting that this implementation is actually problematic. Because preHandle and postHandle are two methods, we have to set a shared Variable start to store the start value, however, there will be thread security issues. Of course, we can solve this problem through other methods. For example, we can solve this problem through ThreadLocal. If you are interested, you
First, spring boot boot mode
1, in the IDE to start the Spring Boot Application project Startup class Appplication.java Main method;
For example: @SpringBootApplicationpublic class Eurekaclientapplication {public static void main
property of the boot plugin
The plugin rewrites the manifest file (MANIFEST.MF, the manifest file inside the jar), which manages the main class (Main-class) and the Start class (Start-class) portal. The main-class in the manifest file is controlled by layout
The start-class here is the of our configuration, and Main-class is controlled by the layout property, don't be confused by the name (isn't it weird?). Look at the solution and see why i
Boot dependency. You can overwrite any version you want, but it will select the Boot version set by default.
Spotify's Docker-maven-plugin plugin is the Docker Image used to build maven1) imagename Specifies the name of the mirror, this example is Springio/lidong-spring-boot
Spring Boot + MyBatis + thymeleaf for simple message board applicationsThis project mainly introduces the use of spring Boot + MyBatis + Thymeleaf + Bootstrap to implement a simple delete and modify (CRUD) message Board application. Advanced people can skip directly.Source code: Https://github.com/qingwenwei/
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.