[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war
创建springboot项目,且不采用<parent>引入springboot时,pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<artifactId>demo-without-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <name>demo-without-parent</name>
<description>Demo project for Spring Boot</description> <properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>
执行
mvn clean install
控制台报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war
原因:当设置为war时,web.xml必须存在。
解决:可通过插件配置属性将其忽略。
首先,spring-boot-dependencies 这个pom文件,找到
<maven-war-plugin.version>3.1.0</maven-war-plugin.version>
找到版本号是3.1.0
然后,在项目的pom.xml中,加入
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
</plugin>
版本号必须与spring-boot-dependencies中maven-war-plugin-version版本号一致。
再次运行mvn clean install ,提示打包成功。
在idea中,运行启动类,成功启动。但是
java -jar demo-without-parent-0.0.1-SNAPSHOT.war 提示:demo-without-parent-0.0.1-SNAPSHOT.war中没有主清单属性
因为,maven-war-plugin的确执行了,但是spring-boot-maven-plugin插件却没有执行,原因在于该插件未指定版本,故设置版本号,依旧是从spring-boot-dependencies中找对应的版本号:2.0.2.RELEASE
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.2.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
重新执行
mvn clean install ,
mvn clean install
java -jar demo-without-parent-0.0.1-SNAPSHOT.war
成功。
最后总结:
1)、maven-war-plugin插件新老版本差异:
2.2:项目中WEB-INF下必须存在web.xml
3.1.0:不需要依赖web.xml
而且,版本号必须与所引入的spring-boot-dependencies下的maven-war-plugin版本号一致。 2)、spring-boot-maven-plugin插件需要配置repackage,否则不会添加spring boot 引导依赖,进而无法引导当前应用。 3)、根据使用习惯通常不会采用spring-boot-dependencies
附,完整pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<artifactId>demo-without-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <name>demo-without-parent</name>
<description>Demo project for Spring Boot</description> <properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.2.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</build> </project>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war的更多相关文章
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:
security-sdk-1.0.jar已经存在于D:/secServerSDK-test/src/main/resources/lib下 报错如下: xxxxxx@xxxxxxxx /d/secSe ...
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (default-cli) on project standalone-pom: Unable to parse configuration of 3: mojo org.apache.maven.plugins:
问题: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (defau ...
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (default-jar) on
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (default-jar) on ...
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project child02
maven打包成war时,报错: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (d ...
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project triage: Compilation failure [ERROR] No compiler is provided in this environment.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-c ...
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project taotao-manager-pojo: Compilation failure
运行maven项目时报错 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compi ...
- Maven进行install的时候报错,COMPILATION ERROR : Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.13:test (default-test) on project cmu: There are test failures.
maven进行install的时候,test类里面报错: COMPILATION ERROR : [INFO] -------------------------------------------- ...
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4: install (default-install) on project authorizationManagement-service: Failed to install metadata com.dmsdbj.itoo:autho
今天在打包时遇到这个问题: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4: inst ...
- mvn clean package:[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12
原文地址:https://www.cnblogs.com/lxcy/p/8279899.html 事故现场: 解决办法: 一是命令行, mvn clean package -Dmaven.test.s ...
随机推荐
- Linux-10Year
主流Linux发行版近10年排行曲线 10个主流的发行版概述(distrowatch挑选) 搜索特定的发行 选择建议 初级用户选择:开箱即用 中级用户组装:适合你自己的系统 高 ...
- bzoj 1138: [POI2009]Baj 最短回文路
额,,貌似网上的题解都说超时之类的. 然而我这个辣鸡在做的时候不知道在想什么,连超时的都不会. 超时的大概是这样的,f[x][y]表示x到y的最短回文路,然后更新的话就是 f[x][y]更新到 f[a ...
- poj 2576 Tug of War
还是神奇的随机算法,,(看视频说这是爬山法??) 其实就是把序列随机分成两半(我太弱,只知道random_shuffle),然后再每个序列里rand一个位置,x,y然后比较是不是交换之后是更优的. 然 ...
- 在 linux 中遇到 OSError: inotify watch limit reached 错误
检查系统当前限制,默认应该是 8192: cat /proc/sys/fs/inotify/max_user_watches 可根据需要调整系统限制,但是目前还不知道如何查看每个进程对 watch 的 ...
- maven项目打包和运行
1. 添加pom <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</ar ...
- 七十二、SAP中内表的修改,添加条件语句,多条目修改
一.代码如下 二.MODIFY执行前断点数据 三.查看到数据如下 四.往下单步走一步,发现有3条数据被修改 五.执行后修改如下
- 155-PHP stripos函数
<?php $str='password'; //定义一个字符串 $position=strpos($str,'S'); //查找字母s第一次出现的位置 echo '字母S的位置是'.$posi ...
- JQuery 多属性选择节点
JQuery 1.6.0+以后用prop()代替attr(); 多属性选择节点 $("input[type=checkbox][name='first2'][value='first4']& ...
- Ubuntu14.04 无法关机 SpamAssassin speech-dispatcher
在ubuntu14.04上安装完一些包后,关闭计算机就会出现关于标题中的两个错误. 1.在软件中心卸载spamAssassin 2.运行命令: sudo update-rc.d -f speech-d ...
- Essay引用如何最大限度的降低抄袭率
今天要说到让无数人恨得要死.为了降重改的哭天喊地的“Paraphrase”.毕竟引用不是打两个引号复制粘贴就能凑字数完事的,无论国内外,都有查重率这个大敌在等着你.想要引用别人的论点论据,就少不了需要 ...