【问题标题】:Directory not creating other than WEB-INF & META-INF in WAR using Maven pom.xml使用 Maven pom.xml 在 WAR 中不创建除 WEB-INF 和 META-INF 之外的目录
【发布时间】:2014-02-28 07:38:36
【问题描述】:

我需要使用 maven(pom.xml) mvn clean install 命令为我的 spring 框架项目创建战争。我的项目 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>

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

我预期的输出文件夹结构

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

【问题讨论】:

  • 你能告诉你文件夹布局和你想把哪个目录放到war文件中吗?
  • 请编辑您的答案,不要将其作为命令发布

标签: java spring maven web-applications directory-structure


【解决方案1】:

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

这个文件夹中的jsp通常会抵抗

\ROOT\src\main\webapp

ROOT 是 pom.xml 抵抗的文件夹。

@另见:maven webapp to place jsps in /WEB-INF/jsp

【讨论】:

  • 我只需要在这个文件夹结构中创建,在maven中可以这样做吗?
【解决方案2】:

需要使用maven-antrun-plugin来创建目录和复制文件。

    <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-locator</id>
<phase>process-sources</phase>
<configuration> 
<tasks>
<mkdir dir="${project.build.directory}/${project.version}/jsp" />
<copy todir="${project.build.directory}/${project.version}/jsp">
<fileset dir="${project.build.directory}/${project.build.finalName}/jsp" />
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-08
    • 1970-01-01
    • 2017-06-22
    • 2014-01-09
    • 2013-01-13
    • 2016-10-02
    • 2014-06-05
    相关资源
    最近更新 更多