我需要使用 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所在的文件夹。
关于java - 使用 Maven pom.xml 在 WAR 中未创建除 WEB-INF 和 META-INF 以外的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22089104/