简体   繁体   中英

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

I need to create war for my spring framework project using maven(pom.xml) mvn clean install command. My Project SpringMVC folder contains jsp and src folder all folder in src is creating inside the web-inf but i need to create jsp and other folder outside web-inf.

pom.xml build tag code

<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>

In war file jsp folder not creating near web-inf. I don't know what else to try.

My Expected Output Folder Structure

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

I think you put the jsp's in the wrong directory.

Typicaly the jsp resist in this folder

\ROOT\src\main\webapp

where ROOT is the folder where the pom.xml resist.

@see also: maven webapp to place jsps in /WEB-INF/jsp

Need to use maven-antrun-plugin for creating directory and copying files.

    <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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM