1.Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
原因:maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常
<build>
<finalName>mmserver</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory ->
<directory>WebContent</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
2.webcontent/images目录下面的空文件夹无法打包到war包中
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
<outputDirectory>${basedir}/target/${project.artifactId}/images/</outputDirectory>
<resources>
<resource>
<directory>WebContent/images/</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
3.在pom.xml中添加了那些依赖的jar后,一旦在代码中应用。当我们本地调试时,会报ClassNotFound错误,这是为什么??
因为Tomcat不懂这些配置,你必须把Maven Dependencies中的jar与发布目录配置好:
项目 —> 属性 -> Deployment Assembly -> Add -> Java Build Path Entries -> 选择Maven Dependencies -> Finish -> OK
这一步就是配置Maven依赖包发布目录,这样调试时会自动把那些jar发布到指定目录下,tomcat也能找到那些jar了。