codecrucible

SpringBoot dynamically reads nacos configuration (configuration hot update)

In a microservices architecture, dynamic updating of configurations is critical to application flexibility and maintainability. Spring Cloud provides a mechanism, the @RefreshScope annotation, to implement hot update of configuration. This article will introduce the principle of configuring hot update and the role of @RefreshScope. Configure hot update principle The principle of configuration hot update is…

Read More

Solving the problem of loss of precision when converting SpringBoot global configuration Long to String

first way Simple and crude, change all Long types to String, and change the database to varchar type; Second way Create your own configuration class extends WebMvcConfigurerAdapter has been deprecated, just implement the WebMvcConfigurer interface directly. @EnableWebMvc @Configuration public class WebDataConvertConfig implements WebMvcConfigurer { public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); ObjectMapper…

Read More

Detailed explanation of @FeignClient in Springboot

I. Overview In a microservice architecture, calls between services are very frequent. In order to simplify calls between services, Spring Boot provides a component called Feign. Feign can help us define and implement RESTful interfaces between services. The @FeignClient annotation is a component in Spring Cloud, implemented based on Netflix Feign. The @FeignClient annotation can…

Read More

SpringBoot——Internationalization

High-quality blog posts: IT-BLOG-CN 1. Steps for writing internationalization in Spring 【1】Write international configuration files; 【2】Use ResourceBundleMessageSource to manage internationalized resource files; 【3】Use ftp:message on the page to retrieve the internationalized content; 2. SpringBoot writing internationalization steps 【1】Create the i18n directory, create the login.properties internationalization default configuration file, and create login_zh_CN.properties at the same time….

Read More

springboot_tomcat turns on the access log, monitors and prints each request address and response time

springboot_tomcat turns on the access log, monitors and prints each request address and response time Foreword Environment Configure the corresponding object information AccessLog configuration default value and description Configuration Example Description of pattern parameter composition Commonly used pattern configurations 7.1 pattern default value 7.2 Default configuration description 7.3 Print the contents of cookies and headers…

Read More

Springboot+logback detailed configuration

Add dependencies Springboot3.0.2 is used here rely <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.32</version> </dependency> “ application.yml placement spring: application: name: chapter002 profiles: active: dev Detailed configuration of logback logback-spring.xml yml file # You can also use a custom name,for examplelogback-config.xml,Just need to be inapplication.ymlJust specify it in the file: logging: config: classpath:logback-config.xml logback-spring.xmlDetailed…

Read More

SpringBoot+ENC implements key encryption and usage principles

😊 @ Author: It’s a flash in the past 💖 @Homepage: https://blog.csdn.net/zhuocailing3390 🎊 @ Community: Java Technology Stack Exchange 🎉 @ Topic: SpringBoot+ENC implements key encryption and usage principles ⏱️ @ Creation time: June 23, 2024 Table of contents Preface Integrate SpringBoot 1.1、POM 1.2. Encryption salt value configuration 1.3. Use of tools 1.4. Encryption configuration…

Read More

Springboot&redisson implements delay queue

Redisson implements delay queue Version Notes: spring boot 2.6.0 redisson-spring-boot-starter 3.28.0 1. Add dependencies & configuration <dependency> <groupId>org.redisson</groupId> <artifactId>redisson-spring-boot-starter</artifactId> <version>3.28.0</version> </dependency> application.properties spring.application.name=springboot-redis-delayed-queue-demo spring.redis.database=2 spring.redis.host=localhost spring.redis.password=123456 spring.redis.port=6379 2. Adding delayed tasks package cn.aohan.delayedqueue.provider; import cn.aohan.delayedqueue.model.DelayedTaskInfo; import cn.aohan.delayedqueue.model.TaskData; import org.redisson.api.RBlockingDeque; import org.redisson.api.RDelayedQueue; import org.redisson.api.RedissonClient; import org.redisson.codec.JsonJacksonCodec; import org.springframework.stereotype.Component; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; /** *…

Read More