springboot static静态方法获取yml配置文件

2025-05-27 15:31:49

1、1.使用IDE打开springboot的代码工程

springboot static静态方法获取yml配置文件

3、3.创建java文件用于后面的测试

springboot static静态方法获取yml配置文件

5、5. 创建一个util.java的帮助工具类,在里面定义静态变量如下,并创建getter和setter静态方法。同时在yml文件中创建需要使用的变量,如图。

springboot static静态方法获取yml配置文件

6、6. 回到步骤4汇总创建的文件中,写下如下代码。最后创建测试文件进行即可。@Configurationpu芟鲠阻缒blic class StaticConfig {@Value("${attachmentPrefixUrl}")private String attachmentPrefixUrl;@Beanpublic int initStatic(){PdfUtils.setAttachmentPrefixUrl(attachmentPrefixUrl);return 0;}}

springboot static静态方法获取yml配置文件
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
相关推荐
  • 阅读量:38
  • 阅读量:40
  • 阅读量:30
  • 阅读量:41
  • 阅读量:92
  • 猜你喜欢