Bladeren bron

增加配置文件读取

tags/v1.0.0^2
林万龙 3 jaren geleden
bovenliggende
commit
777127d168
5 gewijzigde bestanden met toevoegingen van 34 en 6 verwijderingen
  1. +22
    -0
      src/main/java/com/telpo/dipperposition/annotation/MongoSwitch.java
  2. +1
    -2
      src/main/java/com/telpo/dipperposition/config/db/MongoDbContext.java
  3. +6
    -0
      src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java
  4. +1
    -1
      src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java
  5. +4
    -3
      src/main/resources/bootstrap.yaml

+ 22
- 0
src/main/java/com/telpo/dipperposition/annotation/MongoSwitch.java Bestand weergeven

@@ -0,0 +1,22 @@
package com.telpo.dipperposition.annotation;

import java.lang.annotation.*;

/**
* @program: DataPushServer
* @description: mongo数据源切换注解
* @author: linwl
* @create: 2020-07-11 15:06
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MongoSwitch {

/**
* mongo数据库名称
*
* @return
*/
String value() default "";
}

+ 1
- 2
src/main/java/com/telpo/dipperposition/config/db/MongoDbContext.java Bestand weergeven

@@ -22,8 +22,7 @@ import java.util.Map;
public class MongoDbContext {

private static final Map<String, MongoDbFactory> MONGO_CLIENT_DB_FACTORY_MAP = new HashMap<>();
private static final ThreadLocal<MongoDbFactory> MONGO_DB_FACTORY_THREAD_LOCAL =
new ThreadLocal<>();
private static final ThreadLocal<MongoDbFactory> MONGO_DB_FACTORY_THREAD_LOCAL = new ThreadLocal<>();
@Autowired
MongoListProperties mongoListProperties;



+ 6
- 0
src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java Bestand weergeven

@@ -1,5 +1,6 @@
package com.telpo.dipperposition.mapper;

import com.telpo.dipperposition.annotation.MongoSwitch;
import com.telpo.dipperposition.entity.mongo.IPProvinceEntity;
import db.BaseMongoDbDao;
import org.springframework.stereotype.Repository;
@@ -21,11 +22,13 @@ public class IPProvinceMapper extends BaseMongoDbDao<IPProvinceEntity> {
}

@Override
@MongoSwitch("common")
public void save(IPProvinceEntity entity, String collectionName) {
super.save(entity, collectionName);
}

@Override
@MongoSwitch("common")
public void updateFirst(IPProvinceEntity srcObj, IPProvinceEntity targetObj) {
super.updateFirst(srcObj, targetObj);
}
@@ -36,16 +39,19 @@ public class IPProvinceMapper extends BaseMongoDbDao<IPProvinceEntity> {
}

@Override
@MongoSwitch("common")
public List<IPProvinceEntity> queryList(IPProvinceEntity object) {
return super.queryList(object);
}

@Override
@MongoSwitch("common")
public List<IPProvinceEntity> queryList(IPProvinceEntity object, String collectionName) {
return super.queryList(object, collectionName);
}

@Override
@MongoSwitch("common")
public void deleteById(String id) {
super.deleteById(id);
}


+ 1
- 1
src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java Bestand weergeven

@@ -24,7 +24,7 @@ import java.net.InetSocketAddress;
@Slf4j
public class DipperPositionServer {

@Value(value = "${position.serverAddr}")
@Value(value = "${position.server.serverAddr}")
private String serverAddr;

@Value(value = "${position.server.timeAsycPort}")


+ 4
- 3
src/main/resources/bootstrap.yaml Bestand weergeven

@@ -29,6 +29,7 @@ pos:

position:
server:
timeAsycPort:
posAsycPort:
starsAsycPort:
serverAddr: 172.16.192.26
timeAsycPort: 9011
posAsycPort: 9013
starsAsycPort: 9012

Laden…
Annuleren
Opslaan