1,方式一 IDEA配置
步驟一:點擊 edit configurations
步驟二:點擊 Environment
步驟三:點擊 working directory 選擇第三個,點擊應用ok。
2,方式二:添加一個配置文件。
1 @Configuration 2 public class GlobalConfig { 3 @Bean 4 public WebServerFactoryCustomizer<TomcatServletWebServerFactory> customizer() { 5 return (factory) -> { 6 factory.addContextCustomizers((context) -> { 7 //模塊中webapp相對路徑 8 String relativePath = "tt-web/src/main/webapp"; 9 File docBaseFile = new File(relativePath); 10 // 路徑是否存在 11 if (docBaseFile.exists()) { 12 context.setDocBase(docBaseFile.getAbsolutePath()); 13 } 14 } 15 ); 16 }; 17 } 18 }