
jsp項目中運行SpringBootApplication,找不到 /WEB-INF/info.jsp
原因:context路徑問題,資源沒有打包過去
解決方案如下
1.在jsp目錄下 命令行: mvn spring-boot:run
2.添加以下配置類,指明context路徑(不推薦)
@Configuration public class TomcatConfig { @Bean public EmbeddedServletContainerFactory embeddedServletContainerFactory() { ConfigurableEmbeddedServletContainer factory = new TomcatEmbeddedServletContainerFactory(); factory.setDocumentRoot(new File("D:\\Study\\learn-springboot\\module1\\src\\main\\webapp\\")); return (EmbeddedServletContainerFactory) factory; } }
3.更改啟動配置

點擊Edit Configuarations

圖中紅圈去配置路徑,這是idea默認的參數,代表當前項目路徑,也可輸入當前路徑地址
