Вопрос

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
Это было полезно?

Решение 2

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>

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top