首页 > 编程语言 > 详细

SpringBoot2.0 生成组建和读写配置文件

时间:2019-01-27 14:08:36      阅读:164      评论:0      收藏:0      [点我收藏+]
@Component 生成组建
@ConfigurationProperties(prefix="redis")  读写redis配置文件

application.properties配置文件
#redis
redis.host=127.0.0.1
redis.port=6379
redis.timeout=3
redis.password=
redis.poolMaxTotal=10
redis.poolMaxIdle=10
redis.poolMaxWait=3

  

package com.java.seckill.redis;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix="redis")
@AllArgsConstructor
@NoArgsConstructor
@Data
public class RedisConfig {
    private String host;
    private Integer port;
    private Integer timeout;
    private String password;
    private Integer poolMaxTotal;
    private Integer poolMaxIdle;
    private Integer poolMaxWait;
}

  

SpringBoot2.0 生成组建和读写配置文件

原文:https://www.cnblogs.com/wuxiang12580/p/10326199.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!