我有他关注maven web应用程序的结构
当我执行mvn install
命令时,它正在创建war文件,但如果您查看target directory/sureportal
,您可以很容易地看到webapps
目录中的许多子文件夹丢失。有什么问题?
pom.xml文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nokia</groupId>
<artifactId>sureportal</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<name>sureportal Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>sureportal</finalName>
</build>
</project>
答案 0 :(得分:2)
除了sbaitmangalkar的答案,请将maven-war-plugin
插入POM的构建部分:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<!- if you don't have a web.xml, otherwise "true" -->
<failOnMissingWebXml>false</failOnMissingWebXml>
<includeEmptyDirectories>true</includeEmptyDirectories>
<includes>**/*</includes>
<!-- if want your web files to be filterd -->
<webResources>
<resource>
<directory>src/main/webapp</directory>
<includes>
<include>**/*</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/META-INF</directory>
<!-- only if needed in your project -->
<targetPath>/META-INF</targetPath>
<includes>
<include>context.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
这会明确告诉构建过程该做什么。
答案 1 :(得分:2)
您可以拥有maven-war-plugin
并配置为包含空文件夹。
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<includeEmptyDirectories>true</includeEmptyDirectories>
</configuration>
</plugin>
答案 2 :(得分:0)
尝试运行unlink($imagePath . $file_name);
。这将首先清除您编译的文件,并确保所有文件都是从头开始编译的。请查看此主题以获取更多详细信息how-is-mvn-clean-install-different-from-mvn-install