项目中因为webapp目录放到了src同级,所以一直打包加载不到页面,原来maven默认的路径是 src/main/webapp 这样的 ,知道问题就简单了

在pom.xml里面加上配置

<build>		
	<plugins>
		<!-- 修改webapp目录为WebContent -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-war-plugin</artifactId>
			<configuration>
				<!-- 设置WebContent目录为Web目录 -->
				<webappDirectory>src/webapp</webappDirectory>
				<warSourceDirectory>src/webapp</warSourceDirectory>
			</configuration>
		</plugin>
	</plugins>
</build>

这样就可以了,如果你的webapp文件是src同级的话 就直接webapp就可以了

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐