java - 使用 Maven pom.xml 在 WAR 中未创建除 WEB-INF 和 META-INF 以外的目录

标签 java spring maven web-applications directory-structure

我需要使用 maven(pom.xml) mvn clean install 命令为我的 spring 框架项目创建 war。我的项目 SpringMVC 文件夹包含 jsp 和 src 文件夹 src 中的所有文件夹都是在 web-inf 内部创建的,但我需要在 web-inf 外部创建 jsp 和其他文件夹。

pom.xml构建标签代码

<build>
    <finalName>SpringMVC</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
            <webResources>
        <resource>
          <!-- this is relative to the pom.xml directory -->
          <directory>resource2</directory>
          </resource>
          </webResources>
            </configuration>
        </plugin>
    </plugins>
</build>

在 war 文件 jsp 文件夹中未在 web-inf 附近创建。我不知道还能尝试什么。

我预期的输出文件夹结构

SpringMVC.war
 |-- META-INF
 |   |-- MANIFEST.MF
 |   `-- maven
 |       `-- com.example.projects
 |           `-- documentedproject
 |               |-- pom.properties
 |               `-- pom.xml
 |-- WEB-INF
 |   |-- classes
 |   |   |-- com
 |   |   |   `-- example
 |   |   |       `-- projects
 |   |   |           `-- SampleAction.class
 |   |   `-- images
 |   |       `-- sampleimage.jpg
 |   `-- web.xml
 |-- external-resource.jpg
 |-- image2
 |   `-- external-resource2.jpg
 |-- index.jsp
 `-- jsp
     `-- websource.jsp

最佳答案

我认为您将 jsp 放在了错误的目录中。

通常jsp抵抗在这个文件夹中

\ROOT\src\main\webapp

其中ROOT是pom.xml所在的文件夹。

@另请参阅:maven webapp to place jsps in /WEB-INF/jsp

关于java - 使用 Maven pom.xml 在 WAR 中未创建除 WEB-INF 和 META-INF 以外的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22089104/

相关文章:

java - 如何在eclipse中运行这个spring rest maven项目

java - 未知生命周期阶段 “java”

java - 在 eclipse 中作为 TestNG Suite 运行项目时如何生成 Allure xml?

java - 在java中获取解压缩文件的进度

java - Android - 使用 XPath 解析 XML

spring - 自定义 Spring Security 注销过滤器

java - 如何解决此错误 : Caused by: java. lang.InknownClassChangeError: null

javascript - 访问 scriptlet 内的 Java Map

java - 设置 JComboBox 的背景?

java - Spring Web MVC 返回未处理的 View