1. 程式人生 > >intellij idea開發spring boot web遇到jsp及靜態資源無法訪問

intellij idea開發spring boot web遇到jsp及靜態資源無法訪問

本想在springboot中使用下jsp,按照開發步驟一步一步寫,Pom也添加了依賴

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<!--<scope>compile</scope>-->
		</dependency>
		<dependency>
			<groupId>org.apache.tomcat.embed</groupId>
			<artifactId>tomcat-embed-jasper</artifactId>
		</dependency>

結果在intellij idea啟動之後遇到了jsp及靜態資源無法訪問的問題


但是將其mvn clean package之後,部署到獨立tomcat,是可以的


在專案中直接terminal mvn spring-boot:run也是可以的


Running the application from maven is not very nice solution.

Is there any solution, workaround how to work with Spring Boot WAR application with tomcat starter provided and running it from Idea?

懷疑是intellij idea內嵌的tomcat servlet容器中的問題,google一番找到stackoverflow上一篇文章

也是說provided有問題,intelliJ IDEA不會將scope provided依賴項注入到CLASSPATH中,但實際上將scope設定為compile也不可以,所以還沒有找到解決方案