generated from root/miduo_server
初始化保存发货机的内网ip
parent
b30cfabad6
commit
6e3552c86e
|
@ -4,6 +4,8 @@ import com.jmfy.Handler.BaseHandler;
|
||||||
import com.jmfy.Handler.ManagerManager;
|
import com.jmfy.Handler.ManagerManager;
|
||||||
import com.jmfy.controller.ManagerController;
|
import com.jmfy.controller.ManagerController;
|
||||||
import com.jmfy.redisProperties.RedisAutoConfiguration;
|
import com.jmfy.redisProperties.RedisAutoConfiguration;
|
||||||
|
import com.jmfy.server.ServerConfiguration;
|
||||||
|
import com.jmfy.server.ServerProperties;
|
||||||
import com.jmfy.thrift.pool.ThriftPoolUtils;
|
import com.jmfy.thrift.pool.ThriftPoolUtils;
|
||||||
import com.jmfy.util.JsonUtil;
|
import com.jmfy.util.JsonUtil;
|
||||||
import com.jmfy.util.RedisUtil;
|
import com.jmfy.util.RedisUtil;
|
||||||
|
@ -25,13 +27,16 @@ public class Application {
|
||||||
|
|
||||||
//初使化连接池util类
|
//初使化连接池util类
|
||||||
ThriftPoolUtils.getInstance().initContext(configurableApplicationContext);
|
ThriftPoolUtils.getInstance().initContext(configurableApplicationContext);
|
||||||
|
ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class);
|
||||||
|
ServerProperties serverProperties = serverConfiguration.getServerProperties();
|
||||||
// ManagerManager handlerManager = ManagerManager.getInstance();
|
// ManagerManager handlerManager = ManagerManager.getInstance();
|
||||||
// KProducer kProducer = configurableApplicationContext.getBean(KProducer.class);
|
// KProducer kProducer = configurableApplicationContext.getBean(KProducer.class);
|
||||||
// KProducer.init();
|
// KProducer.init();
|
||||||
//redis初始化
|
//redis初始化
|
||||||
RedisAutoConfiguration redisAutoConfiguration = configurableApplicationContext.getBean(RedisAutoConfiguration.class);
|
RedisAutoConfiguration redisAutoConfiguration = configurableApplicationContext.getBean(RedisAutoConfiguration.class);
|
||||||
RedisUtil.getInstence().init(redisAutoConfiguration.getRedisProperties());
|
RedisUtil.getInstence().init(redisAutoConfiguration.getRedisProperties());
|
||||||
JsonUtil.getInstence().initServerIPandProt();
|
|
||||||
|
RedisUtil.getInstence().initServerIPandProt(serverProperties);
|
||||||
// Map<String, BaseHandler> commandHanderMap = configurableApplicationContext.getBeansOfType(BaseHandler.class);
|
// Map<String, BaseHandler> commandHanderMap = configurableApplicationContext.getBeansOfType(BaseHandler.class);
|
||||||
// for (BaseHandler handler : commandHanderMap.values()){
|
// for (BaseHandler handler : commandHanderMap.values()){
|
||||||
// handlerManager.addHandler(handler);
|
// handlerManager.addHandler(handler);
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.jmfy.server;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by a on 2017/7/5.
|
||||||
|
*/
|
||||||
|
@Configuration(value = "serverConfiguration")
|
||||||
|
@EnableConfigurationProperties(ServerProperties.class)
|
||||||
|
public class ServerConfiguration {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ServerProperties serverProperties;
|
||||||
|
|
||||||
|
public ServerProperties getServerProperties() {
|
||||||
|
return serverProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.jmfy.server;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by a on 2017/7/5.
|
||||||
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "server")
|
||||||
|
public class ServerProperties {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private String deliveryAddress;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeliveryAddress() {
|
||||||
|
return deliveryAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeliveryAddress(String deliveryAddress) {
|
||||||
|
this.deliveryAddress = deliveryAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ServerProperties{" +
|
||||||
|
"id=" + id +
|
||||||
|
", deliveryAddress='" + deliveryAddress + '\'';
|
||||||
|
}
|
||||||
|
}
|
|
@ -79,16 +79,4 @@ public class JsonUtil {
|
||||||
String dayBefore=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
|
String dayBefore=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
|
||||||
return dayBefore;
|
return dayBefore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initServerIPandProt() {
|
|
||||||
InetAddress ia=null;
|
|
||||||
try {
|
|
||||||
ia=ia.getLocalHost();
|
|
||||||
String deliveryAddress = ia.getHostAddress() +":"+9991;
|
|
||||||
LOGGER.info("initServerIPandProt=>deliveryAddress={}",deliveryAddress);
|
|
||||||
RedisUtil.getInstence().putMapEntry(RedisUserKey.IP_AND_PROT_MAP, String.valueOf(9991),deliveryAddress,3,-1);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.jmfy.util;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.jmfy.redisProperties.RedisProperties;
|
import com.jmfy.redisProperties.RedisProperties;
|
||||||
import com.jmfy.redisProperties.RedisUserKey;
|
import com.jmfy.redisProperties.RedisUserKey;
|
||||||
|
import com.jmfy.server.ServerProperties;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||||
|
@ -363,4 +364,8 @@ public class RedisUtil {
|
||||||
delObject(type, key);
|
delObject(type, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void initServerIPandProt(ServerProperties serverProperties) {
|
||||||
|
String deliveryAddress = serverProperties.getDeliveryAddress();
|
||||||
|
RedisUtil.getInstence().putMapEntry(RedisUserKey.IP_AND_PROT_MAP, String.valueOf(9991),deliveryAddress,3,-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
server.port=9991
|
server.port=9991
|
||||||
##contextPath
|
##contextPath
|
||||||
server.context-path=/delivery
|
server.context-path=/delivery
|
||||||
|
server.deliveryAddress=60.1.1.12:9991
|
||||||
# redis config
|
# redis config
|
||||||
spring.redis.host = 150.116.94.74
|
spring.redis.host = 150.116.94.74
|
||||||
spring.redis.port = 6379
|
spring.redis.port = 6379
|
||||||
|
@ -10,6 +10,7 @@ spring.redis.password = redis.ljsd.COM@
|
||||||
spring.redis.expireTime = -1
|
spring.redis.expireTime = -1
|
||||||
|
|
||||||
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/ysj_core
|
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/ysj_core
|
||||||
|
|
||||||
#
|
#
|
||||||
#spring.data.mongodb.host=192.168.0.170
|
#spring.data.mongodb.host=192.168.0.170
|
||||||
#spring.data.mongodb.port=27017
|
#spring.data.mongodb.port=27017
|
||||||
|
|
Loading…
Reference in New Issue