分享一下项目究竟怎么运行起来。。。。。小问题配置了半天,凌晨3点。。
Topic source因为资产是启动时初始化在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));
}
...
}
- 1
自由
环境: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文件夹下的脚本开始自动交易