mirror of
https://github.com/qiurunze123/miaosha.git
synced 2023-11-19 22:41:03 +08:00
update config
This commit is contained in:
parent
24acc80920
commit
9455fd6e37
|
@ -30,13 +30,13 @@ public class AccessInterceptor extends HandlerInterceptorAdapter{
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
if(handler instanceof HandlerMethod) {
|
if(handler instanceof HandlerMethod) {
|
||||||
MiaoshaUser user = getUser(request, response);
|
|
||||||
UserContext.setUser(user);
|
|
||||||
HandlerMethod hm = (HandlerMethod)handler;
|
HandlerMethod hm = (HandlerMethod)handler;
|
||||||
AccessLimit accessLimit = hm.getMethodAnnotation(AccessLimit.class);
|
AccessLimit accessLimit = hm.getMethodAnnotation(AccessLimit.class);
|
||||||
if(accessLimit == null) {
|
if(accessLimit == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
MiaoshaUser user = getUser(request, response);
|
||||||
|
UserContext.setUser(user);
|
||||||
int seconds = accessLimit.seconds();
|
int seconds = accessLimit.seconds();
|
||||||
int maxCount = accessLimit.maxCount();
|
int maxCount = accessLimit.maxCount();
|
||||||
boolean needLogin = accessLimit.needLogin();
|
boolean needLogin = accessLimit.needLogin();
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.geekq.miaosha.config;
|
package com.geekq.miaosha.config;
|
||||||
|
|
||||||
|
import com.geekq.miaosha.access.AccessInterceptor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,8 +15,18 @@ public class WebConfig extends WebMvcConfigurerAdapter {
|
||||||
@Autowired
|
@Autowired
|
||||||
UserArgumentResolver userArgumentResolver;
|
UserArgumentResolver userArgumentResolver;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AccessInterceptor accessInterceptor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
super.addInterceptors(registry);
|
||||||
|
registry.addInterceptor(accessInterceptor);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||||
argumentResolvers.add(userArgumentResolver);
|
argumentResolvers.add(userArgumentResolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class RedisPoolFactory {
|
||||||
poolConfig.setMaxTotal(redisConfig.getPoolMaxTotal());
|
poolConfig.setMaxTotal(redisConfig.getPoolMaxTotal());
|
||||||
poolConfig.setMaxWaitMillis(redisConfig.getPoolMaxWait() * 1000);
|
poolConfig.setMaxWaitMillis(redisConfig.getPoolMaxWait() * 1000);
|
||||||
JedisPool jp = new JedisPool(poolConfig, redisConfig.getHost(), redisConfig.getPort(),
|
JedisPool jp = new JedisPool(poolConfig, redisConfig.getHost(), redisConfig.getPort(),
|
||||||
redisConfig.getTimeout()*1000, redisConfig.getPassword(), 0);
|
redisConfig.getTimeout()*1000, redisConfig.getPassword(), 8);
|
||||||
return jp;
|
return jp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class RedissonAutoConfiguration {
|
||||||
RedissonClient redissonSingle() {
|
RedissonClient redissonSingle() {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
SingleServerConfig serverConfig = config.useSingleServer()
|
SingleServerConfig serverConfig = config.useSingleServer()
|
||||||
|
.setDatabase(9)
|
||||||
.setAddress(redssionProperties.getAddress())
|
.setAddress(redssionProperties.getAddress())
|
||||||
.setTimeout(redssionProperties.getTimeout())
|
.setTimeout(redssionProperties.getTimeout())
|
||||||
.setConnectionPoolSize(redssionProperties.getConnectionPoolSize())
|
.setConnectionPoolSize(redssionProperties.getConnectionPoolSize())
|
||||||
|
|
|
@ -53,8 +53,8 @@ redis.poolMaxIdle=500
|
||||||
redis.poolMaxWait=500
|
redis.poolMaxWait=500
|
||||||
|
|
||||||
# redisson lock
|
# redisson lock
|
||||||
redisson.address=redis://localhost:6379
|
redisson.address=redis://10.4.34.24:30009
|
||||||
redisson.password=123456
|
redisson.password=qazwsx.com
|
||||||
#rabbitmq
|
#rabbitmq
|
||||||
spring.rabbitmq.host=localhost
|
spring.rabbitmq.host=localhost
|
||||||
spring.rabbitmq.port=5672
|
spring.rabbitmq.port=5672
|
||||||
|
|
|
@ -16,9 +16,9 @@ mybatis.mapperLocations=classpath:mybatis/mapper/*.xml
|
||||||
#add mybatis
|
#add mybatis
|
||||||
mybatis.config-locations=classpath:mybatis/config.xml
|
mybatis.config-locations=classpath:mybatis/config.xml
|
||||||
#datasource
|
#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.username=root
|
||||||
spring.datasource.password=aixiyue11
|
spring.datasource.password=123qwe!@#
|
||||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||||
#druid
|
#druid
|
||||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
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.chain.html-application-cache=true
|
||||||
spring.resources.static-locations=classpath:/static/
|
spring.resources.static-locations=classpath:/static/
|
||||||
#redis
|
#redis
|
||||||
redis.host=192.168.1.116
|
redis.host=10.4.34.24
|
||||||
redis.port=6379
|
redis.port=30009
|
||||||
redis.timeout=100
|
redis.timeout=100
|
||||||
redis.password=123456
|
redis.password=qazwsx.com
|
||||||
redis.poolMaxTotal=1000
|
redis.poolMaxTotal=1000
|
||||||
redis.poolMaxIdle=500
|
redis.poolMaxIdle=500
|
||||||
redis.poolMaxWait=500
|
redis.poolMaxWait=500
|
||||||
#server.port=8003
|
#server.port=8003
|
||||||
|
|
||||||
|
redisson.address=redis://10.4.34.24:30009
|
||||||
|
redisson.password=qazwsx.com
|
||||||
|
|
||||||
#rabbitmq
|
#rabbitmq
|
||||||
spring.rabbitmq.host=localhost
|
spring.rabbitmq.host=10.4.34.24
|
||||||
spring.rabbitmq.port=5672
|
spring.rabbitmq.port=30672
|
||||||
spring.rabbitmq.username=guest
|
spring.rabbitmq.username=liudz
|
||||||
spring.rabbitmq.password=guest
|
spring.rabbitmq.password=qazwsx.c0m
|
||||||
spring.rabbitmq.virtual-host=/
|
spring.rabbitmq.virtual-host=/
|
||||||
spring.rabbitmq.listener.simple.concurrency= 10
|
spring.rabbitmq.listener.simple.concurrency= 10
|
||||||
spring.rabbitmq.listener.simple.max-concurrency= 10
|
spring.rabbitmq.listener.simple.max-concurrency= 10
|
||||||
|
|
|
@ -27,6 +27,6 @@
|
||||||
|
|
||||||
<context:component-scan base-package="com.geekq.miaosha" />
|
<context:component-scan base-package="com.geekq.miaosha" />
|
||||||
|
|
||||||
<import resource="classpath:/dubbo_consumer.xml" />
|
<!--<import resource="classpath:/dubbo_consumer.xml" />-->
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user