Maven报错处理方法汇总

来源:互联网 发布:.net cms 编辑:程序博客网 时间:2024/05/29 15:10

1.现象:

用maven编译web工程,最后打出的war包WEB-INF目录下没有src/main/resources/目录下的配置文件

解决方法:

在pom.xml加上

<build>      <resources>          <resource>              <directory>src/main/java</directory>            </resource>          <resource>        <directory>src/main/resources</directory>        </resource>    </resources>  </build>  

2.现象:

部署Web项目报错

webxml attribute is required
解决方法:

maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常。

需要在pom.xml中增加<webResources>配置,如下:

<build>  <finalName>simple-webapp</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>  
或者增加<webXml>配置,如下:
<build>  <finalName>simple-webapp</finalName>  <plugins>      <plugin>          <groupId>org.apache.maven.plugins</groupId>          <artifactId>maven-war-plugin</artifactId>          <version>2.1.1</version>          <configuration>            <webXml>WebContent\WEB-INF\web.xml</webXml>                 </configuration>      </plugin>  </plugins>   </build>  




0 0
原创粉丝点击