我正在使用nestjs(https://github.com/nestjs/nest/tree/master/sample/03-microservices)的微服务混合示例来熟悉基础知识。当前,它使用位于src文件夹(src / math)中的微服务。我想将微服务移到微服务文件夹(microservices / math / ...)下的根文件夹中,以便可以在此结构中构建其他微服务。
当我使用“ start:prod”:“ node dist / main.js”运行它时,如果我要在app.module.ts中导入的math.module是一个示例,在'./math/ math.module'正常工作。如果我将数学文件夹内容复制到根目录中的microservices文件夹中,并且从“ ../microservices/math.module”引用了math.module,那么在我拥有的地方dist结构是错误的:
当然,在这种情况下,它将尝试在“ dist”中运行main.js,但不再存在,因为它会自动放置在src而不是dist文件夹的根中。
这纯粹是我需要调整的打字稿配置吗?
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./"
},
"exclude": ["node_modules"]
}
tsconfig.build.json
{
"extends": "./tsconfig.json",
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
答案 0 :(得分:0)
这里的问题是,当您从文件夹中import
include
未在用于构建的tsconfig.json
中void getLoginAction(ActionEvent event) throws IOException, Exception {
String username = tfUsername.getText();
String password = tfPassword.getText();
loggingUsers.setUserName(username);
loggingUsers.setPassword(password);
FileHandler userFh = new FileHandler("UserLog.txt", true);
SimpleFormatter sf = new SimpleFormatter();
userFh.setFormatter(sf);
uLog.addHandler(userFh);
uLog.setLevel(Level.INFO);
try {
ObservableList<User> loginInfo = DatabaseMan.getActiveUsers();
loginInfo.forEach((u) -> {
try {
assert loggingUsers.getUserName().equals(u.getUserName()) && loggingUsers.getPassword().equals(u.getPassword()) : "Incorrect login info!";
loggingUsers.setUserId(u.getUserId());
try {
Appointment upcomingAppt = DatabaseAppointments.getUpcomingAppt();
if (!(upcomingAppt.getAppointmentId() == 0)) {
Alert apptAlert = new Alert(Alert.AlertType.INFORMATION);
apptAlert.setTitle("Upcoming Appointment Reminder");
apptAlert.setHeaderText("You have an upcoming appointment!");
apptAlert.setContentText("You have an appointment scheduled"
+ "\non " + upcomingAppt.getStart().format(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL))
+ "\nat " + upcomingAppt.getStart().format(DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL))
+ " with client " + upcomingAppt.getCustomer().getCustomerName() + ".");
apptAlert.showAndWait();
if (apptAlert.getResult() == ButtonType.OK) {
userLog.log(Level.INFO, "User: {0} logged in.", loggingUsers.getUserName());
Stage loginStage = (Stage) btnLogin.getScene().getWindow();
loginStage.close();
FXMLLoader apptCalLoader = new FXMLLoader(AppointmentCalendarController.class.getResource("MainAppointment.fxml"));
Parent calScreen = calLoader.load();
Scene calScene = new Scene(calScreen);
Stage calStage = new Stage();
calStage.setTitle("Appointment Calendar");
calStage.setScene(apptCalScene);
calStage.show();
}
else {
apptAlert.close();
}
}
else {
userLog.log(Level.INFO, "User: {0} logged in.", loggingUsers.getUserName());
FXMLLoader apptCalLoader = new FXMLLoader(AppointmentCalendarController.class.getResource("MainAppointment.fxml"));
Parent calScreen = calLoader.load();
Scene calScene = new Scenec(calScreen);
Stage calStage = new Stage();
calStage.setTitle("Appointment Calendar");
calStage.setScene(apptCalScene);
calStage.show();
Stage loginStage = (Stage) btnLogin.getScene().getWindow();
loginStage.close();
}
}
catch (IOException e) {
e.printStackTrace();
}
}
catch (AssertionError e) {
System.out.println(e.getMessage());
this.lblAlert.setText(this.rb.getString("lblErrorAlert") + ".");
this.lblAlert.setTextFill(Paint.valueOf("RED"));
userLog.log(Level.WARNING, "Invalid credentials entered! User: {0}", loggingUsers.getUserName());
}
});
}
catch (Exception e) {
e.printStackTrace();
}
}
时,在这种情况下,打字稿将使用代码进入最不深层文件夹的父文件夹中,并构建该文件夹树的结构,因为构建的文件之间应具有相同的相对路径。