打包war出错
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xu</groupId>
<artifactId>maven-xu</artifactId>
<version>1.0.0-list</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.48</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
</plugins>
</build>
</project>
出错提示
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.xu:maven-xu >---------------------------
[INFO] Building maven-xu 1.0.0-list
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-xu ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-xu ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-xu ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-xu ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-xu ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.930 s
[INFO] Finished at: 2019-08-15T17:32:07+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project maven-xu: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test: org/apache/commons/lang3/StringUtils
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-surefire-plugin:2.12.4
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/Administrator/Desktop/后端/jar/org/apache/maven/plugins/maven-surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.jar
[ERROR] urls[1] = file:/C:/Users/Administrator/Desktop/后端/jar/org/apache/maven/surefire/surefire-booter/2.12.4/surefire-booter-2.12.4.jar
[ERROR] urls[2] = file:/C:/Users/Administrator/Desktop/后端/jar/org/apache/maven/surefire/surefire-api/2.12.4/surefire-api-2.12.4.jar
[ERROR] urls[3] = file:/C:/Users/Administrator/Desktop/后端/jar/org/apache/maven/surefire/maven-surefire-common/2.12.4/maven-surefire-common-2.12.4.jar
[ERROR] urls[4] = file:/C:/Users/Administrator/Desktop/后端/jar/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
[ERROR] urls[5] = file:/C:/Users/Administrator/Desktop/后端/jar/org/apache/maven/shared/maven-common-artifact-filters/1.3/maven-common-artifact-filters-1.3.jar
[ERROR] urls[6] = file:/C:/Users/Administrator/Desktop/后端/jar/org/codehaus/plexus/plexus-utils/3.0.8/plexus-utils-3.0.8.jar
[ERROR] urls[7] = file:/C:/Users/Administrator/Desktop/后端/jar/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
[ERROR] urls[8] = file:/C:/Users/Administrator/Desktop/后端/jar/org/apache/maven/plugin-tools/maven-plugin-annotations/3.1/maven-plugin-annotations-3.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.apache.commons.lang3.StringUtils
[ERROR] -> [Help 1]
[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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
正在回答 回答被采纳积分+1
同学,你好!先了解一下你现在的情况,之前创建maven工程有没有报错,还是打war包之后才出问题的?
因为maven是和网络有关,如果网不好也会报错。可以确认一下网络状况,多尝试一下。
下面说一下创建maven工程的步骤,参照这个再做一遍试试。
1、选择菜单File——New——Maven Project
2、如下页面是存储位置,可以选择自己的文件夹,然后点击Next
3、在下面的界面中选择如下选中的内容,然后点击Next
4、然后填写相关内容,点击Finish
5、我这里建完后是有错误的,jsp文件报错。
6、打开indexjsp,提示在Java Build Path中没有HttpServlet.
可以鼠标右键工程,选择Build Path——Configure Build Path,在打开的界面中选择Add Library
然后选择Server Runtime
在如下界面中,选择你的Tomcat服务器,点击OK。如果这里没有服务器,可以提前创建好
点击Finish,返回上一级页面,然后选中下面的内容,点击Remove,将J2SE 1.5移除
然后选择Add Library,添加JDK 8,此时选择JRE System Library
点击Next后,选择Workspace默认的JRE,然后点击Finish
配置完的效果如下,选择Apply,此时错误就消失了,并且运行程序是没问题的。
如果创建工程没问题了,再试试打war包。
如果我的回答解决了你的疑惑,请采纳!祝学习愉快!
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星