diff --git a/source/deployment/deployment-gateway/src/main/java/com/jd/blockchain/gateway/boot/GatewayBooter.java b/source/deployment/deployment-gateway/src/main/java/com/jd/blockchain/gateway/boot/GatewayBooter.java index f6c637ad..4c9d5537 100644 --- a/source/deployment/deployment-gateway/src/main/java/com/jd/blockchain/gateway/boot/GatewayBooter.java +++ b/source/deployment/deployment-gateway/src/main/java/com/jd/blockchain/gateway/boot/GatewayBooter.java @@ -18,7 +18,6 @@ public class GatewayBooter { writePID(); GatewayServerBooter.main(args); } catch (Exception e) { - e.printStackTrace(); System.err.println("Error!!! --[" + e.getClass().getName() + "] " + e.getMessage()); } } diff --git a/source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java b/source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java index 76c39b61..bdc8e881 100644 --- a/source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java +++ b/source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java @@ -2,6 +2,7 @@ package com.jd.blockchain.gateway; import java.io.File; import java.io.InputStream; +import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -23,10 +24,14 @@ import com.jd.blockchain.utils.ConsoleUtils; public class GatewayServerBooter { + private static final String DEFAULT_GATEWAY_PROPS = "application-gw.properties"; + // 当前参与方在初始化配置中的参与方列表的编号; private static final String HOST_ARG = "-c"; + //sp;针对spring.config.location这个参数进行包装; private static final String SPRING_CF_LOCATION = BaseConstant.SPRING_CF_LOCATION; + // 是否输出调试信息; private static final String DEBUG_OPT = "-debug"; @@ -57,11 +62,20 @@ public class GatewayServerBooter { }else { //if no the config file, then should tip as follows. but it's not a good feeling, so we create it by inputStream; ConsoleUtils.info("no param:-sp, format: -sp /x/xx.properties, use the default application-gw.properties "); - ClassPathResource configResource = new ClassPathResource("application-gw.properties"); + ClassPathResource configResource = new ClassPathResource(DEFAULT_GATEWAY_PROPS); InputStream in = configResource.getInputStream(); - File targetFile = new File(System.getProperty("user.dir")+File.separator+"conf"+File.separator+"application-gw.properties"); + + // 将文件写入至config目录下 + String configPath = bootPath() + "config" + File.separator + DEFAULT_GATEWAY_PROPS; + File targetFile = new File(configPath); + + // 先将原来文件删除再Copy + if (targetFile.exists()) { + FileUtils.forceDelete(targetFile); + } + FileUtils.copyInputStreamToFile(in, targetFile); - springConfigLocation = "file:"+targetFile.getAbsolutePath(); + springConfigLocation = "file:" + targetFile.getAbsolutePath(); } // 启动服务器; @@ -147,4 +161,17 @@ public class GatewayServerBooter { return appCtx; } + private static String bootPath() throws Exception { + URL url = GatewayServerBooter.class.getProtectionDomain().getCodeSource().getLocation(); + String currPath = java.net.URLDecoder.decode(url.getPath(), "UTF-8"); + // 处理打包至SpringBoot问题 + if (currPath.contains("!/")) { + currPath = currPath.substring(5, currPath.indexOf("!/")); + } + if (currPath.endsWith(".jar")) { + currPath = currPath.substring(0, currPath.lastIndexOf("/") + 1); + } + System.out.printf("Current Project Boot Path = %s \r\n", currPath); + return new File(currPath).getParent() + File.separator; + } } \ No newline at end of file diff --git a/source/peer/src/main/java/com/jd/blockchain/peer/web/ManagementController.java b/source/peer/src/main/java/com/jd/blockchain/peer/web/ManagementController.java index cf4b8bac..9e771a33 100644 --- a/source/peer/src/main/java/com/jd/blockchain/peer/web/ManagementController.java +++ b/source/peer/src/main/java/com/jd/blockchain/peer/web/ManagementController.java @@ -111,7 +111,8 @@ public class ManagementController implements LedgerBindingConfigAware, PeerManag DataContractRegistry.register(BftsmartConsensusSettings.class); DataContractRegistry.register(BftsmartNodeSettings.class); -// DataContractRegistry.register(LedgerAdminDataQuery.class); + DataContractRegistry.register(LedgerAdminInfo.class); + DataContractRegistry.register(LedgerSettings.class); }