application.properties
server.port=8002 spring.application.name=service-oss spring.profiles.active=dev aliyun.oss.file.endpoint=xxxxxxxxxxxxxxxxx aliyun.oss.file.keyid=xxxxxxxxxxxxxxxxx aliyun.oss.file.keysecret=xxxxxxxxxxxxx aliyun.oss.file.bucketname=xxxxxxxxxxx
定义实体类CompentProperties读取配置文件内容:
package com.atguigu.servieceoss.utils; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class CompentProperties implements InitializingBean { // 读取配置文件内容 @Value("${aliyun.oss.file.endpoint}") private String endpoint; @Value("${aliyun.oss.file.keyid}") private String keyId; @Value("${aliyun.oss.file.keysecret}") private St