> 文档中心 > 完美解决:springboot使用jsp打包后404问题

完美解决:springboot使用jsp打包后404问题

网上提供的方式大多是将maven plugin换成1.4.2.RELEASE。这种方式放在工程上明显欠妥。所以研究了一下,得出了一个可用的方案:不用更换打包插件版本,而是在原版本上把前端代码放置到正确的位置即可。
springboot使用jsp的相关配置不是本文重点,故不在此赘述。
本文的重点是解决打包后404的问题。
springboot下,前端代码默认放置在classpath/static或者classpath/template下,static的优先级在前。
故,打包时将前端相关的代码打包到static下即可。maven相关的配置如下:

<build>    <plugins> <plugin>     <groupId>org.spring framework.boot<groupId>     <artifactId>spring-boot-maven-plugin<artifactId> <plugin>    <plugins>    <resources> <resource>    <directory>src/main/webapp</directory>  <targetPath>${project.build.directory}/classes/static</targetPath> <resource> <resource>   <directory>src/main/resources</directory>     <targetPath>${project.build.directory}/classes</targetPath> <resource>    <resources><build>