Discuss / Java / 分享一下项目究竟怎么运行起来。。。。。小问题配置了半天,凌晨3点。。

分享一下项目究竟怎么运行起来。。。。。小问题配置了半天,凌晨3点。。

Topic source

自由

#1 Created at ... [Delete] [Delete and Lock User]

环境:PC+已安装mysql在3306端口的WIN10+IDEA+Dockerdesktop,全部都在本地(注意你的电脑已经安装且常驻运行的mysql服务是万恶之源

0.在IDEA启动configApplication  (首先启动这个别关,不装Docker都能启动)

1.通过cmd文件在在build目录下运行docker-compose up -d启动Docker容器。  (记得改docker-compose文件里的mysql端口号为3305:3306还有application.yml文件内的mysql的url改为localhost:3305)

2.通过IDEA设置Docker for windows,百度一下就有。确保连接上docker,可以看到4个image。

3.通过IDEA的最下方的服务栏目里一键启动剩下的几个Application,注意如果你手动一个一个启动,要按顺序否则报错,比如UI就依赖于tradingAPI启动。

4.进入http://localhost:8000/signin 可以看到界面了

5.通过bot文件夹下的脚本开始自动交易

Nyyswdsxjj

#2 Created at ... [Delete] [Delete and Lock User]

哇,谢谢你!你真善良啊

大狮子头

#3 Created at ... [Delete] [Delete and Lock User]

bot脚本一直报 {"error":"NO_ENOUGH_ASSET","data":null,"message":"No enough available asset"}

大狮子头

#4 Created at ... [Delete] [Delete and Lock User]

重新signup一个用户就初始化了,不知道user0-9为啥没有。

大狮子头

#5 Created at ... [Delete] [Delete and Lock User]

因为资产是启动时初始化在Map当中了。改了一点代码,每次启动就初始化。

public class MvcController extends LoggerSupport {
  ...
  public void init() {
      // 本地开发环境下自动创建用户user0@example.com ~ user9@example.com:    if (isLocalDevEnv()) {
          for (int i = 0; i <= 9; i++) {
              String email = "user" + i + "@example.com";
              String name = "User-" + i;
              String password = "password" + i;
              UserProfileEntity userProfileEntity = userService.fetchUserProfileByEmail(email);
              if (userProfileEntity == null) {
                    logger.info("auto create user {} for local dev env...", email);
                  doSignup(email, name, password);
              }else {
                    deposit(userProfileEntity);
              }
          }
      }
  }
  ...
  private UserProfileEntity doSignup(String email, String name, String password) {
     // sign up:    
      UserProfileEntity profile = userService.signup(email, name, password);    
      if (isLocalDevEnv()) {
          deposit(profile);    
      }
      logger.info("user signed up: {}", profile);    
      return profile;
  }

  private void deposit(UserProfileEntity profile) {
      // 本地开发环境下自动给用户增加资产:
      logger.warn("auto deposit assets for user {} in local dev env...", profile.email);
      Random random = new Random(profile.userId);
      deposit(profile.userId, AssetEnum.BTC, new BigDecimal(random.nextInt(5_00, 10_00)).movePointLeft(2));
      deposit(profile.userId, AssetEnum.USD,
              new BigDecimal(random.nextInt(100000_00, 400000_00)).movePointLeft(2));
  }
  ...
}

朱门中人

#6 Created at ... [Delete] [Delete and Lock User]

@大狮子头 ,重新注册一个用户,所有用户都获得了资产数据,这个比较靠谱。

另外上述改造的代码,在事件执行的时候会去重,不再继续执行,资产还是获取不到的


  • 1

Reply