From 9455fd6e37db03b7202c547f241d5375aa8d6f5e Mon Sep 17 00:00:00 2001 From: "jay1991115@126.com" Date: Wed, 5 Dec 2018 13:26:00 +0800 Subject: [PATCH] update config --- .../miaosha/access/AccessInterceptor.java | 4 ++-- .../com/geekq/miaosha/config/WebConfig.java | 12 +++++++++++ .../geekq/miaosha/redis/RedisPoolFactory.java | 2 +- .../redis/RedissonAutoConfiguration.java | 1 + src/main/resources/application-dev.properties | 4 ++-- src/main/resources/application.properties | 21 +++++++++++-------- src/main/resources/dubbo/springmvc.xml | 2 +- 7 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/geekq/miaosha/access/AccessInterceptor.java b/src/main/java/com/geekq/miaosha/access/AccessInterceptor.java index 40b075e..b03c630 100644 --- a/src/main/java/com/geekq/miaosha/access/AccessInterceptor.java +++ b/src/main/java/com/geekq/miaosha/access/AccessInterceptor.java @@ -30,13 +30,13 @@ public class AccessInterceptor extends HandlerInterceptorAdapter{ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if(handler instanceof HandlerMethod) { - MiaoshaUser user = getUser(request, response); - UserContext.setUser(user); HandlerMethod hm = (HandlerMethod)handler; AccessLimit accessLimit = hm.getMethodAnnotation(AccessLimit.class); if(accessLimit == null) { return true; } + MiaoshaUser user = getUser(request, response); + UserContext.setUser(user); int seconds = accessLimit.seconds(); int maxCount = accessLimit.maxCount(); boolean needLogin = accessLimit.needLogin(); diff --git a/src/main/java/com/geekq/miaosha/config/WebConfig.java b/src/main/java/com/geekq/miaosha/config/WebConfig.java index 3399845..a151838 100644 --- a/src/main/java/com/geekq/miaosha/config/WebConfig.java +++ b/src/main/java/com/geekq/miaosha/config/WebConfig.java @@ -1,8 +1,10 @@ package com.geekq.miaosha.config; +import com.geekq.miaosha.access.AccessInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import java.util.List; @@ -13,8 +15,18 @@ public class WebConfig extends WebMvcConfigurerAdapter { @Autowired UserArgumentResolver userArgumentResolver; + @Autowired + private AccessInterceptor accessInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + super.addInterceptors(registry); + registry.addInterceptor(accessInterceptor); + } + @Override public void addArgumentResolvers(List argumentResolvers) { argumentResolvers.add(userArgumentResolver); } + } diff --git a/src/main/java/com/geekq/miaosha/redis/RedisPoolFactory.java b/src/main/java/com/geekq/miaosha/redis/RedisPoolFactory.java index e1bc05a..582be54 100644 --- a/src/main/java/com/geekq/miaosha/redis/RedisPoolFactory.java +++ b/src/main/java/com/geekq/miaosha/redis/RedisPoolFactory.java @@ -20,7 +20,7 @@ public class RedisPoolFactory { poolConfig.setMaxTotal(redisConfig.getPoolMaxTotal()); poolConfig.setMaxWaitMillis(redisConfig.getPoolMaxWait() * 1000); JedisPool jp = new JedisPool(poolConfig, redisConfig.getHost(), redisConfig.getPort(), - redisConfig.getTimeout()*1000, redisConfig.getPassword(), 0); + redisConfig.getTimeout()*1000, redisConfig.getPassword(), 8); return jp; } diff --git a/src/main/java/com/geekq/miaosha/redis/RedissonAutoConfiguration.java b/src/main/java/com/geekq/miaosha/redis/RedissonAutoConfiguration.java index b26fb69..a3c3dcb 100644 --- a/src/main/java/com/geekq/miaosha/redis/RedissonAutoConfiguration.java +++ b/src/main/java/com/geekq/miaosha/redis/RedissonAutoConfiguration.java @@ -50,6 +50,7 @@ public class RedissonAutoConfiguration { RedissonClient redissonSingle() { Config config = new Config(); SingleServerConfig serverConfig = config.useSingleServer() + .setDatabase(9) .setAddress(redssionProperties.getAddress()) .setTimeout(redssionProperties.getTimeout()) .setConnectionPoolSize(redssionProperties.getConnectionPoolSize()) diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 1a58b00..917e014 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -53,8 +53,8 @@ redis.poolMaxIdle=500 redis.poolMaxWait=500 # redisson lock -redisson.address=redis://localhost:6379 -redisson.password=123456 +redisson.address=redis://10.4.34.24:30009 +redisson.password=qazwsx.com #rabbitmq spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 14355ce..b6adb57 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,9 +16,9 @@ mybatis.mapperLocations=classpath:mybatis/mapper/*.xml #add mybatis mybatis.config-locations=classpath:mybatis/config.xml #datasource -spring.datasource.url=jdbc:mysql://localhost:3306/miaosha?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false +spring.datasource.url=jdbc:mysql://10.4.34.24:30006/miaosha?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false spring.datasource.username=root -spring.datasource.password=aixiyue11 +spring.datasource.password=123qwe!@# spring.datasource.driver-class-name=com.mysql.jdbc.Driver #druid spring.datasource.type=com.alibaba.druid.pool.DruidDataSource @@ -44,20 +44,23 @@ spring.resources.chain.gzipped=true spring.resources.chain.html-application-cache=true spring.resources.static-locations=classpath:/static/ #redis -redis.host=192.168.1.116 -redis.port=6379 +redis.host=10.4.34.24 +redis.port=30009 redis.timeout=100 -redis.password=123456 +redis.password=qazwsx.com redis.poolMaxTotal=1000 redis.poolMaxIdle=500 redis.poolMaxWait=500 #server.port=8003 +redisson.address=redis://10.4.34.24:30009 +redisson.password=qazwsx.com + #rabbitmq -spring.rabbitmq.host=localhost -spring.rabbitmq.port=5672 -spring.rabbitmq.username=guest -spring.rabbitmq.password=guest +spring.rabbitmq.host=10.4.34.24 +spring.rabbitmq.port=30672 +spring.rabbitmq.username=liudz +spring.rabbitmq.password=qazwsx.c0m spring.rabbitmq.virtual-host=/ spring.rabbitmq.listener.simple.concurrency= 10 spring.rabbitmq.listener.simple.max-concurrency= 10 diff --git a/src/main/resources/dubbo/springmvc.xml b/src/main/resources/dubbo/springmvc.xml index 1abc0d5..ad4d377 100644 --- a/src/main/resources/dubbo/springmvc.xml +++ b/src/main/resources/dubbo/springmvc.xml @@ -27,6 +27,6 @@ - +