1、创建需要读取的properties文件
2、在xml文件中加载配置文件
<!-- 加载配置文件 -->
<context:property-placeholder location="classpath:conf/resource.properties" />
3、使用@Value注解调用该属性
1、创建需要读取的properties文件
2、在xml文件中加载配置文件
<!-- 加载配置文件 -->
<context:property-placeholder location="classpath:conf/resource.properties" />
3、使用@Value注解调用该属性
【IDEA】idea设置默认maven配置, 避免每次设置maven
开发时经常要读取properties文件的配置信息,但是properties文件所在的位置和properties访问方式不同读取方式也不同,现就读取properties文件进行总结。1、访问方式一般分:java项目和web项目。2、文件位置:与源文件相同目录和与源目录不相同java项目与源文件相同目录读取properties文件方法,在main函数中读取import java.io.FileInp
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M