簡體   English   中英

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

[英]Directory not creating other than WEB-INF & META-INF in WAR using Maven pom.xml

我需要使用maven(pom.xml)mvn clean install命令為我的spring框架項目創建戰爭。 我的Project 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將jsps放在/ WEB-INF / jsp中

需要使用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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM