首页 > 其他分享 >应用启动时加载application.properties配置文件

应用启动时加载application.properties配置文件

时间:2023-05-28 17:11:36浏览次数:51  
标签:String 配置文件 regionId sms public application secret aliyun properties

配置

aliyun.sms.regionId=default
aliyun.sms.accessKeyId=LTAIxxx
aliyun.sms.secret=PAxxxx

 

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ConstantPropertiesUtils implements InitializingBean {

    @Value("${aliyun.sms.regionId}")
    private String regionId;

    @Value("${aliyun.sms.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.sms.secret}")
    private String secret;

    //对外提供
    public static String REGION_Id;
    public static String ACCESS_KEY_ID;
    public static String SECRECT;

    @Override
    public void afterPropertiesSet() throws Exception {
        REGION_Id=regionId;
        ACCESS_KEY_ID=accessKeyId;
        SECRECT=secret;
    }
}

 

标签:String,配置文件,regionId,sms,public,application,secret,aliyun,properties
From: https://www.cnblogs.com/ixtao/p/17438505.html

相关文章

  • apache配置文件之虚拟主机配置
    虚拟主机的配置(1)基于IP地址的虚拟主机配置Listen80<VirtualHost172.20.30.40>DocumentRoot/www/example1ServerNamewww.example1.com</VirtualHost><VirtualHost172.20.30.50>DocumentRoot/www/example2ServerNamewww.example2.......
  • webapplication.createBuilder一些记录
    internalWebApplicationBuilder(WebApplicationOptionsoptions,Action<IHostBuilder>?configureDefaults=null){varconfiguration=newConfigurationManager();configuration.AddEnvironmentVariables(prefix:"ASPNETCORE_&quo......
  • .net core 读取配置文件项
    ///<summary>///配置文件服务///</summary>publicclassAppConfigurtaionServices{///<summary>///配置文件对象///</summary>publicstaticIConfigurationConfiguration{get;set;}......
  • springboot添加多个环境的配置文件
    1,在resources目录下面新建application.properties,application-dev.properties,application-pre.properties,application-prod.properties2,在application.properties只添加一行要激活的环境,其他不用添加spring.profiles.active=dev3,其他属性文件根据需要配置不同的属性......
  • 一份采用单例模式编写,可读取配置文件的代码
    Confaccess.h#ifndef__CONFACCESS_H__#define__CONFACCESS_H__#include<pthread.h>#include<stdlib.h>#include<string>#include<map>classCConfAccess{public:staticCConfAccess*getInstance(){......
  • FLEX AIR实践—删除ApplicationDirectory目录下文件
    AIR的文件目录类型有以下几种:File.userDirectory                                //指向用户文件夹File.documentsDirectory                      //指向用户文档文件夹File.desktopDirectory           ......
  • 使用resource读取properties文件,出现Cause: java.sql.SQLException: No suitable driv
    ###Errorqueryingdatabase.Cause:java.sql.SQLException:Nosuitabledriverfoundforhttp://maven.apache.org###Theerrormayexistincom/louis/dao/UserMapper.xml###Theerrormayinvolvecom.louis.dao.UserMapper.getUserList###Theerroroccurred......
  • 如何将日志配置文件放入到Apollo配置中心并支持热更新
    增加监听日志文件(LoggerConfiguration.java)@ServicepublicclassLoggerConfiguration{privatestaticfinalLoggerlogger=LoggerFactory.getLogger(LoggerConfiguration.class);privatestaticfinalStringLOGGER_TAG="logging.level.";@Autowired......
  • FLEX实践—模拟Application与Module间的事件监听
         一直找到如何在Application中发出一个事件,让Module捕获该事件并做出相应的动作。但是一直没找到,于是模拟了一个这样的情景。 WatchTest.mxml<?xmlversion="1.0"encoding="utf-8"?><mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"layout="absolute"......
  • Distributed System and Application
    Assignment2:DistributedSystemandApplicationCloudComputingandDistributedSystems(CLOUDS)LaboratorySchoolofComputingandInformationSystemsTheUniversityofMelbourne,AustraliaOthercontributors:AllTutors2Project:DistributedSharedWhiteBoa......