MAVEN 错误

本文详细解析了Maven开发过程中遇到的常见错误,包括错误页面配置、webxml属性缺失及依赖本地jar包等问题,并提供了相应的解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Maven学习笔记

 
 错误1:An error has occurred when creating this preference page

解决办法:
将环境变量Path中%JAVA_HOME%\bin;置于path最前面解决问题

 

 错误2:webxml attribute is required

1
2
3
4
5
6
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) ->
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:

 

    解决:maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常。解决方法在pom.xml加入以下的配置。红色背景字体改成你网站的根目录。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<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>

 

 记录3:dependency引用本地jar包

1
2
3
4
5
6
7
<dependency>
<groupId>org.apache</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/paypal_base.jar</systemPath>
</dependency>

maven使用module开发生成web工程,不打war包方法

 

1
mvn clean complie process-classes war:exploded

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值