当前位置:网站首页>项目参数做成可配置项,@ConfigurationProperties注解的使用
项目参数做成可配置项,@ConfigurationProperties注解的使用
2022-07-27 03:38:00 【时间是一种解药】
项目参数做成可配置项,@ConfigurationProperties注解的使用
问题背景
项目中,许多参数是要做成可配置的,现在而且有了nacos的支持,可配置可以不用重启,动态更改了,非常方便
ConfigurationProperties的使用
1 导入提示依赖
<!--配置页的提示工具-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
2 创建可配置类
package com.lanran.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/** * @Description: * @Created: IDEA2021 * @author: 蓝染 * @createTime: 2022-07-23 20:28 **/
//跟配置文件绑定,前缀为lanran.thread
@ConfigurationProperties(prefix = "lanran.thread")
// @Component
@Data
public class ThreadPoolConfigProperties {
private Integer coreSize;
private Integer maxSize;
private Integer keepAliveTime;
}
3 application配置文件示例
#配置线程池,可配置文件
lanran.thread.coreSize=20
lanran.thread.maxSize=200
lanran.thread.keepAliveTime=10
作为程序员第 216 篇文章,每次写一句歌词记录一下,看看人生有几首歌的时间,wahahaha …


Lyric: 擦干是否就看不见你
边栏推荐
- playwright网络爬虫实战案例分享
- 微服务化解决文库下载业务问题实践
- PX4模块设计之十二:High Resolution Timer设计
- Elastic open source community: Developer Recruitment
- Golang JWT cross domain authentication
- Five basic data structures of redis
- Cool Lehman VR panorama paves the way for you to start a business
- Detailed analysis of trajectory generation tool in psins toolbox
- Knowledge atlas: knowledge representation
- List Simulation Implementation
猜你喜欢

11. Zuul routing gateway

"Gonna be right" digital collection is now on sale! Feel the spiritual resonance of artists

Introduction to JVM principle

什么是动画效果?什么是过渡效果?

Is VR panorama just needed now? After reading it, you will understand

E-commerce system combined with commodity spike activities, VR panorama continues to bring benefits

Principle of bean validation --07

卷积神经网络——灰度图像的卷积

【MySQL系列】MySQL索引事务

2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。 package main import ( “fmt“ ) type integer in
随机推荐
leetcode每日一练:将句子排序
Ribbon-负载均衡原理及部分源码
大咖说·图书分享|精益产品开发:原则、方法与实施
C get UUID
2022 operation of simulated examination question bank and simulated examination platform for safety production management personnel of hazardous chemical production units
Interview question 02.05. sum of linked list
微服务化解决文库下载业务问题实践
356 pages, 140000 words, weak current intelligent system of high-end commercial office complex, 2022 Edition
细说Hash(哈希)
Brightcove任命Dan Freund为首席营收官
[Code] sword finger offer 04 search in two-dimensional array
【MySQL系列】MySQL索引事务
[untitled]
CloudCompare&PCL 匹配点中值(或标准差)距离抑制
centos如何安装mysqldump
What is animation effect? What is the transition effect?
Rust:axum learning notes (1) Hello World
Stm32cubemx learning notes (41) -- eth interface +lwip protocol stack use (DHCP)
tcp协议知识详解
E-commerce system combined with commodity spike activities, VR panorama continues to bring benefits