SpringBoot2.0 redis生成组建和读写配置文件
程序员文章站
2022-03-10 15:57:49
@Component 生成组建 @ConfigurationProperties(prefix="redis") 读写redis配置文件application.properties配置文件 #redis redis.host=127.0.0.1 redis.port=6379 redis.timeo... ......
@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;
}
上一篇: Jsp 好的入门文章共赏