问题:springboot项目,有html的静态文件,启动springboot项目后访问不了静态文件。

分析:编译的时候没有把静态文件编译进target/classes下。

问题解决:pom文件下build节点下添加resources节点

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>2.1.0.RELEASE</version>
			</plugin>
		</plugins>
		<resources>
			<resource>
				<directory>src/main/webapp</directory>
				<targetPath>META-INF/resources</targetPath>
				<includes>
					<include>**/**</include>
				</includes>
			</resource>
		</resources>
	</build>

重新编译,发现静态文件编译到了classes下,访问成功。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐