springboot打包成jar无法访问jsp页面的解决方法

时间:2025-03-19 09:55:08

springboot打包成jar,无法访问jsp 页面的解决方法:

  • 将maven打包插件的版本改为1.4.2
      <plugin>
        <groupId></groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>1.4.</version>
      </plugin>
  • 配置 < resources>将webapp打包进target/classes 目录,其中< targetPath>META-INF/resources</ targetPath> 指定将webapp打包到target/classes 目录的META-INF/resources 目录下,必须这样配置,否则会出错
  <resources>
    <resource>
      <directory>src/main/webapp</directory>
      <targetPath>META-INF/resources</targetPath>
    </resource>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
  </resources>