1. Overview of global configuration files The global configuration file can modify some default configuration values. Spring Boot uses an application.properties or application.yaml file as a global configuration file, which is stored in the src/main/resource directory or /config in the class path, and the resource directory is generally selected. 2. Application.properties configuration file (1) Create […]
Tag: spring
Spring Boot two global configurations and two annotations
Article directory Zero. Learning Objectives 1. Overview of the global configuration file Two, Application.properties configuration file 1. Create Spring Boot’s Web project PropertiesDemo (1) Create a project using Spring Initializr 2. Add relevant configuration in the application properties file 3. Configuration and use of object types (1) Create the Pet class (2) Create the Person […]
springboot integrates Redis to save commodity and commodity inventory information
1. Add dependencies and configuration <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> Add the following configuration in application.yaml: spring: redis: # address host: localhost # port, default is 6379 port: 6379 # password password: # Connection timeout timeout: 10s lettuce: pool: # The minimum idle connection in the connection pool min-idle: 0 # The maximum idle connection in […]
How to dynamically refresh the configuration of SpringBoot (scheme)
For microservices, configuration localization is a big problem. It is impossible to restart the service every time you need to change the configuration. Therefore, the final solution is to externalize the configuration and host it on a platform to achieve unnecessary Restart the service to modify multiple valid purposes at once. But for the Spring […]
This deep analysis of the execution process of SpringMVC will help you improve to a higher level immediately after reading it!
Follow the WeChat public account “Java Architecture Stack”, reply [Interview Collection], and immediately receive a full set of testing resources. Preface Hello everyone, I am Brother Qianfengwen. In the previous article, Brother Wen introduced the construction process of the SpringMVC entry case. I believe that everyone has a basic understanding of the basic use of […]
What is the role of MergedBeanDefinitionPostProcessor in Spring?
What is the role of MergedBeanDefinitionPostProcessor in Spring? introduction call timing Several ways to load bean definitions postProcessMergedBeanDefinition interface function summary Introduction MergedBeanDefinitionPostProcessor is a Bean post-processor that you may pay less attention to, and it only provides a bean lifecycle callback interface: public interface MergedBeanDefinitionPostProcessor extends BeanPostProcessor {<!– –> void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, […]
SpringBoot master-slave data source switching, Mybatis Plus annotation method association query
1. Project structure 2. Main code 1 Use druid to configure the master-slave data source # data source configuration spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver druid: # Main database data source db1: url: jdbc:mysql://47.93.96.145:3306/xiaozhu_database?useUnicode=true & amp;characterEncoding=utf8 & amp;zeroDateTimeBehavior=convertToNull & amp;useSSL=true & amp;serverTimezone=GMT+8 username: root password: xiaozhu123456 # From the database data source (temporarily local) db2: […]
Springmvc concepts and simple cases
springmvc concept The JavaEE architecture includes four layers, from top to bottom are the application layer, Web layer, business layer, and persistence layer. Struts and SpringMVC are the frameworks of the Web layer, Spring is the framework of the business layer, and Hibernate and MyBatis are the frameworks of the persistence layer. SpringMVC is a […]
How to dynamically refresh the configuration of SpringBoot (custom)
The custom part of this article includes 1. Custom refresh event (with RefreshScope to achieve automatic refresh) 2. Force refresh the context (restart the entire ApplicationContext) 3. Implement Http interface loading of configuration files (similar to Nacos) Custom refresh event (with RefreshScope to achieve automatic refresh) Manual refresh of configuration based on org.springframework.cloud.context.config.annotation.RefreshScope Spring uses […]
Spring IOC and Bean scope and life cycle
Directory 1. What is spring IOC? 2. Understanding of IOC/DI 3.Bean scope 4. Bean life cycle 5. Summary of omissions in the previous article 1. What is spring IOC? The spring container is mainly the implementation of the IOC design pattern. It mainly uses containers to unify management of Bean objects and manage dependencies between […]