1. Preface SpringBoot 2.6.x does not recommend the use of circular dependencies, which is good news, SpringBoot is gradually guiding developers to write standard code from the bottom up, but also sad news, circular dependencies are too widely used. If you upgrade from a low version to 2.6.x, then the first problem you are likely to encounter is a circular dependency problem. 2. Problem recovery 2.1. Code description The following style of code is more common: both classes have the need to call each other’s methods, so it is easy to write a circular reference.
Anyone who has used WebSecurityConfigurerAdapter knows that it is very important for Spring Security, it manages the whole Spring Security configuration system. But soon this class will be obsolete, you read it right, this class will be marked by @Deprecated in version 5.7 and this class will be removed in the future(#10822). Since this configuration class will be deprecated soon, there must be a transition plan. I’ve actually written an
How is the order of built-in filters maintained in Spring Security? I think many developers are interested in this question. In this article, I will discuss this issue with you. HttpSecurity contains a member variable FilterOrderRegistration and this class is a built-in filter registry. As for the role of these filters, not the focus of this article, interested to see the FilterOrderRegistration source code. Order of built-in filters The FilterOrderRegistration
Environment represents the environment information for the entire spring application runtime, which contains two key elements. profiles properties profiles The concept of profiles, which I believe we all understand, is most commonly used in different environments to determine different configuration contexts for solutions in the current spring container. For example, for the development environment, test environment, production environment, build different application.properties configuration items, this time we can determine the current spring application context in effect through the property profiles.
1. Preface Software iteration is a problem that developers must face, and one issue that is easily overlooked these days is API version control. Not all users are keen on the latest version of software, and business is fluid. So when a new version is released to ensure backward compatibility, API version control is needed. Today we will discuss the common Restful API version control. 2. API Version Control Restful
1. Preface Most of the developers contacted in Java development do not pay much attention to testing the interface, resulting in various problems in the docking. Some also use tools such as Postman for testing, although there is no problem in the use of the interface, if the interface increases the permissions testing is more disgusting. So it is recommended to test the interface in unit testing to ensure the
1. Preface Swagger 3.0 has been released for some time now, and has been used by more and more projects as a very useful documentation tool. And JWT is also the most commonly used security technology for front-end and back-end separation. So how do you add JWT Token to Swagger 3.0? 2. Adding JWTs in Swagger2 Let’s first review how JWT was added in Swagger2. In Swagger2 we declare the
Spring Cloud 2021.0.1 is released, the first bugfix release of Spring Cloud 2021. Support for 2021.0.0 Smooth Upgrade is now available from the central repository at the following coordinates. maven: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>2021.0.1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> .
1. Preface When developing Spring Boot applications, you can inject Bean into the Spring IoC container based on conditions. For example, if a configuration property exists in the configuration file, then the Bean is injected. The red part of the diagram means that the class tagged with @Configuration can only be injected into Spring IoC if ali.pay.v1.app-id is present in the environment configuration of Spring. The @ConditionalOnProperty in this case
1. Preface We previously analyzed the details of the initialization of AuthenticationManager, and there was a piece of code in it that caught the attention of many people. 1 2 ApplicationContext context = http.getSharedObject(ApplicationContext.class); CaptchaAuthenticationProvider captchaAuthenticationProvider = context.getBean("captchaAuthenticationProvider", CaptchaAuthenticationProvider.class); How does the above get the Spring application context object ApplicationContext directly from the HttpSecurity object? And what is the concept of SharedObject? Let’s figure this out today. 2. SharedObject In Spring Security SharedObject is neither an object nor an interface, but a generic term for a class of “sharable” objects.
The client uploads the video to the server, the server slices the video, AES encrypts it, and returns the m3u8 index file, cover and other information. It can be played online. The server can do some simple processing of the video, such as cropping, cover interception time. Video folder layout 1 2 3 4 5 6 mymovie # The folder name is the video title |-index.m3u8 #the main m3u8 file,
After springboot starts, its process id needs to be recorded and written to a disk file. The bash script can easily stop the program by PID. ApplicationPidFileWriter A listener provided by springboot is very simple. Just add the listener instance to the SpringApplication before starting the springboot application. 1 2 3 SpringApplication springApplication = new SpringApplication(MyApplication.class); springApplication.addListeners(new ApplicationPidFileWriter()); // Pid Listener springApplication.run(args); Configure the write file for the process ID.
Monitoring is often critical in enterprise-level applications. Monitoring can help us prevent failures, predict trends, alert when thresholds are reached, and provide more information to troubleshoot production problems. If we don’t know how our program is running, it will take more time to troubleshoot when there is an accident in the online system. If we can monitor in advance, we can prepare early so that we don’t get confused after
Recently, I took a look at the restart scripts of the project and found that Ops has been using kill-9<pid> to restart springboot embedded tomcat, in fact, we almost unanimously agree that kill-9<pid> is a more violent way, but few people can analyze what problems it will bring. This article mainly records my own thinking process. What is the difference between kill -9 and kill -15? In the old days,
Problem Discovery Today this topic is still relatively easy, and many of you may have encountered this problem. The @RestController, @ResponseBody and other annotations are the ones we deal with most when writing web applications, and we often have the need to return an object to the client, which SpringMVC helps us serialize into JSON objects. And today I want to share the topic is not something profound, it is
Recently, we have been particularly disturbed by various security vulnerabilities, and we receive dozens of emails a week from security teams scanning for vulnerabilities. One of these vulnerabilities is easy to overlook, but has a very wide impact and is extremely harmful. You shouldn’t be surprised when I say its name, it’s the Spring Boot Actuator. Before writing this article, I did a little survey with my friends asking them about their knowledge of the Spring Boot Actuator and the results were amazingly consistent.
Unit testing of Controllers is a capability natively supported by the Spring Framework, which simulates an HTTP client initiating a request to a service address and allows testing of the interface without the use of external tools such as Postman. Specifically, the implementation is provided by the spring-test module of the Spring Framework, see MockMvc. The following section details how to use the MockMvc test framework to implement unit tests
This article briefly talks about the hook interfaces CommandLineRunner and ApplicationRunner, which are sometimes referred to as Runner in the following. Runner callback timing Refer to the source code of the org.springframework.boot.SpringApplication#run() method. You can know the timing of the callbacks for CommandLineRunner and ApplicationRunner. Before all CommandLineRunner and ApplicationRunner callbacks, the following steps have been ensured to be executed. Environment built-in variables are created and properties are populated. Banner
Feign framework does not directly support file uploads (Multipart/form-data). Need to integrate the module feign-form to achieve . Using Feign independently Adding module dependencies. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <!-- Feign框架核心 --> <dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-core</artifactId> <version>11.1</version> </dependency> <!-- 支持表单格式，文件上传
Today I want to talk to you about the monitoring function in Druid. Druid database connection pool believe that many people have used, I feel that Druid is a more successful open source project Ali, unlike Fastjson has so many problems. druid has been better in all aspects, full-featured, easy to use, the basic usage will not say, today we look at the monitoring function in Druid. 1. Preparation First