Discuss / 手写Spring / /step-by-step/hello-boot 执行 main 函数运行 tomcat 报错需更正 webDir 和 baseDir

/step-by-step/hello-boot 执行 main 函数运行 tomcat 报错需更正 webDir 和 baseDir

Topic source

R8HLR6CC

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

String webDir = isJarFile ? "tmp-webapp" : "src/main/webapp";

SummerApplication.run(webDir, isJarFile ? "tmp-webapp" : "target/classes", HelloConfiguration.class, args);

更正为

String webDir = isJarFile ? "tmp-webapp" : "step-by-step/hello-boot/src/main/webapp";

SummerApplication.run(webDir, isJarFile ? "tmp-webapp" : "step-by-step/hello-boot/target/classes", HelloConfiguration.class, args);

即可

R8HLR6CC

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

这样子的话每个子项目都得手动编辑 webDir 和 baseDir 吗?请问廖老师有没有什么解决办法啊?

廖雪峰

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

你的IDE配置有问题,把启动目录自动设置为项目根目录,这样才能用相对目录

R8HLR6CC

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

已解决,廖老师牛,这边顺便贴下idea的设置方法

导航栏 - RUN - Edit Configurations - Defaults - Application - Working directory 设置为 $MODULE_DIR$

参考链接


  • 1

Reply