【SpringBoot基础】Spring El 表达式读取配置

本文介绍了如何在Spring Boot中利用Spring EL表达式读取配置文件内容。通过注解方式将配置注入到容器中,便于后续操作。文章包含环境依赖、项目文件结构、配置类BeanSpringEl的实现及测试类Main的代码示例,展示了具体的操作流程和输出结果。
摘要由CSDN通过智能技术生成

【SpringBoot基础】Spring El 表达式读取配置

内容概要

使用 spring 支持的注解方式,读取系统文件中的配置,注入到容器中,方便调用。

环境jar包

	jdk: jdk1.8.0_121(32位)
	pom:
		 <dependency>
	           <groupId>org.springframework</groupId>
	           <artifactId>spring-context</artifactId>
	           <version>5.0.10.RELEASE</version>
	     </dependency>
	     <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.0.1</version>
        </dependency>

文件结构

在这里插入图片描述
test.properties 内容
在这里插入图片描述
test.txt内容
在这里插入图片描述

EL配置类 BeanSpringEl

package SpringEl;

import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值