【慕课网架构师网课笔记】--属性资源文件与类映射

1.在springboot项目的resources目录下新建file-upload-prod.properties

##路径  mac是/  windows是 \\
file.imageUserFaceLocation=/Users/wl/project/foodie-dev/images/foodie/faces

2.在项目中新建类,引入配置类

@Component
@ConfigurationProperties(prefix = "file")
@PropertySource("classpath:file-upload-dev.properties")
@Data
public class FileUpload {

    private String imageUserFaceLocation;

}

3.在Controller类中注入FileUpload,并调用方法

@RestController
@RequestMapping("userInfo")
public class CenterUserController extends BaseController {
	
	@Autowired
    private FileUpload fileUpload;
    
    //定义头像的保存地址
    String fileSpace = fileUpload.getImageUserFaceLocation();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值