配置文件 spring: #数据库连接信息 datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/tliasxitong username: root password: 1234 #spring: # datasource: # driver-class-name: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://localhost:3306/tliasxitong # username: root # password: 1234 servlet: multipart: max-file-size: 10MB max-request-size: 100MB mybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl map-underscore-to-camel-case: true #配置需要的资源 aliyun: tlias: endpoint: oss-cn-beijing.aliyuncs.com accessKeyId: LTAI5tRiJHCiuKR22W1ZWCDo accessKeySecret: 2GzS6wF1O86LPRtv1GIv3LynqV7NhX bucketName: tiliassss # 需要实现提示依赖 # <dependency> # <groupId>org.springframework.boot</groupId> # <artifactId>spring-boot-configuration-processor</artifactId> # </dependency>
2.提取配置文件数据
//抽取配置文件数据 //@lombut 实现get和set方法 @Data @Component //批量实现配置文件自动按照名字查找写法 @ConfigurationProperties(prefix = "aliyun.tlias") public class aliastilias { // 实现单独一个 配置指定文件数据写法 // @Value("${aliyun.oss .endpoint}") String endpoint ; String accessKeyId ; String accessKeySecret; String bucketName ;