当前位置: 首页 > news >正文

烟台网站开发丹东做网站的公司

烟台网站开发,丹东做网站的公司,求邯郸网站制作,淘宝网网页版登陆网址boot读取配置文件1. yml配置文件2. 绑定方式13. 绑定方式23.1 依赖.3.2 boot 中提供的属性装配功能。1. 在某些业务中#xff0c;需要将类的配置写到配置文件中, 不在代码中写死配置。 2. 所以需要读取配置文件(yaml, properties) 读取到Java Bean中。 3. 本文以oss对象存储配… boot读取配置文件1. yml配置文件2. 绑定方式13. 绑定方式23.1 依赖.3.2 boot 中提供的属性装配功能。1. 在某些业务中需要将类的配置写到配置文件中, 不在代码中写死配置。 2. 所以需要读取配置文件(yaml, properties) 读取到Java Bean中。 3. 本文以oss对象存储配置为demo。两种方式初始化配置文件。1. yml配置文件 server:port: 8888spring:application:name: hello-world# oss对象存储配置 oss-constant:endpoint: secretaccess-key: keysecret-key: keybucket: bucket2. 绑定方式1 使用Value注解, 注入配置文件的值。 好处能够选择性的配置。能够类名.属性。 坏处写死了Value(value“xxx”) 前缀项目打包后了不方便修改。 package top.bitqian.hello.constant;import lombok.Data; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component;/*** 加载oss对象存储配置* author echo lovely* date 2021/3/20 09:30*/Data Component public class OssLoadConstant implements InitializingBean {Value(${oss-constant.endpoint})private String endpoint;Value(${oss-constant.access-key})private String accessKeyId;Value(${oss-constant.secret-key})private String accessKeySecret;Value(${oss-constant.bucket})private String bucketName;public static String ENDPOINT;public static String ACCESS_KEY_ID;public static String ACCESS_KEY_SECRET;public static String BUCKET_NAME;Overridepublic void afterPropertiesSet() {// 初始化设置值ENDPOINT this.endpoint;ACCESS_KEY_ID this.accessKeyId;ACCESS_KEY_SECRET this.accessKeySecret;BUCKET_NAME this.bucketName;}} 3. 绑定方式2 3.1 依赖. dependencies!-- 属性装配提示 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-configuration-processor/artifactIdoptionaltrue/optional/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdexecutionsexecution!-- 打包时排除 属性装配提示插件 --configurationgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-configuration-processor/artifactId/configuration/execution/executions/plugin/plugins/build 3.2 boot 中提供的属性装配功能。 yaml中的前缀和下面的ConfigurationProperties的prefix对应。 yaml中的属性和实体类属性对应。(yaml中的横杠可以转驼峰) package top.bitqian.hello.constant;import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component;/*** 此Java类与配置文件绑定了.* author echo lovely* date 2021/3/20 09:36*//*1. 绑定方法1:ComponentConfigurationProperties(prefix oss-constant)2. 绑定方法2:实体配置类, ConfigurationProperties(prefix oss-constant)在配置类上开启和配置文件(yml, properties)绑定 :EnableConfigurationProperties(value {OssConstantConfig.class})*/Data Component ConfigurationProperties(prefix oss-constant) public class OssConstantConfig {private String endpoint;private String accessKey;private String secretKey;private String bucket; } 获取的话从容器中获取就行了。配置文件中的值会自动装配到Java Bean中。
http://www.yutouwan.com/news/471926/

相关文章:

  • 室内设计网站知乎网上举报平台
  • 一学一做教育视频网站新浪云 wordpress
  • 淘宝客网站做百度推广鹤壁seo推广
  • 凡客vancl的网站标题网站建设与管理维护
  • 十大电子游戏平台网站常平网站建设公司
  • 给工厂做代加工上海专业seo
  • 网站开发描述wordpress邀请码教程
  • 网站有图片的验证码是怎么做的网站导航栏设计要求
  • 江西建设安全网站重庆设计集团
  • 烟台百度网站排名资讯wordpress主题
  • 网站维护的基本内容包括哪些杭州seo软件
  • 天津做网站哪个公司好代理公司收费标准
  • dw制造网站log怎么做网站建设和平面设计
  • 网站上的图片做多大微商城开发需要多少钱
  • 在线相册jsp网站开发与设计网页界面设计怎么做
  • 网站都有什么类型的线上营销课程哪里学
  • 建设地情网站的作用嵌入式开发工程师需要学什么
  • 什么编程语言做网站安全番禺人才网招聘网官网
  • 重庆网站建设公司 菠拿拿哪些网站可以做装修
  • 产品设计私单网站建立网站 优帮云
  • 网站域名密码忘了网站备案资料查询
  • 网站建设费属于哪个会计科目建设银行的网站是多少
  • 阿里巴巴自助建站的一般流程广东网站建设定制
  • 建设校园网站的意义phpwind 转wordpress
  • 没钱怎么做网站做网站合肥
  • 上海网站制作公司哪家百度竞价规则
  • 网站设计哪家强成都网站建设龙兵
  • 网站发布的方法有几种.net可以做网站做游戏 博客园
  • 用地方别名做网站名wordpress获取分类目录连接
  • ftp网站服务器梅州在建高铁最新消息