008-SpringBoot发布WAR启动报错:Error assembling WAR: webxml attribute is required
一、Spring Boot发布war包流程:
1、修改web model的pom.xml
<packaging>war</packaging>
SpringBoot默认发布的都是jar,因此要修改默认的打包方式jar为war
2、修改web model的依赖(dependency)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件,或者scope = provided
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
-->
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency> <!--<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>-->
注意:
这里添加了起步依赖spring-boot-starter-web,因此,建议把起步依赖Spring-boot-starter-tomcat的scope设置为provided,原因很简单:我们的项目中可能会使用Filter等Servlet的api;
因此,不建议spring-boot-starter-web中移除嵌入式Spring-boot-starter-tomcat的起步依赖,因为这样就必须再单独添加servet-api的依赖
3、maven编译
启动时报错:Error assembling WAR: webxml attribute is required
很明显:webapp/WEB-INF下找不到web.xml
使用Spring开发,默认把所有的静态资源+界面view都放在resources下了,如下图:

因此,webapp都不复存在了,更何况/WEB-INF和/WEB-INF/web.xml
解决方案:
<!-- 没有web.xml文件的情况下构建WAR
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>
-->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<!--如果想在没有web.xml文件的情况下构建WAR,请设置为false。-->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
1、使用maven-war-plugin3.0,解决了web.xml不存在无法构建war的问题
2、继续使用maven-war-plugin2.6,添加设置failOnMissingWebXml=false
008-SpringBoot发布WAR启动报错:Error assembling WAR: webxml attribute is required的更多相关文章
- Tomcat7.0.40注册到服务启动报错error Code 1 +connector attribute sslcertificateFile must be defined when using ssl with apr
Tomcat7.0.40 注册到服务启动遇到以下几个问题: 1.启动报错errorCode1 查看日志如下图: 解决办法: 这个是因为我的jdk版本问题,因为电脑是64位,安装的jdk是32位的所以会 ...
- android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037:
android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 问题原因: ...
- SpringBoot发布WAR启动报错:Error assembling WAR: webxml attribute is required
Spring Boot发布war包流程: 1.修改web model的pom.xml <packaging>war</packaging> SpringBoot默认发布的都是j ...
- springboot启动报错,Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
报错: Error starting ApplicationContext. To display the conditions report re-run your application with ...
- 【maven 报错】maven项目执行maven install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
在使用maven新建的web项目中,执行 执行如上的这两个操作,报错: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-co ...
- tomcat启动报错 ERROR o.a.catalina.session.StandardManager 182 - Exception loading sessions from persiste
系统:centos6.5 x86_64 jdk: 1.8.0_102 tomcat:8.0.37 tomcat 启动报错: ERROR o.a.catalina.session.StandardMan ...
- Tomcat启动报错ERROR:transport error 202:bind failed:Address already
昨天在服务器上拷贝了一个tomcat项目,修改了server.xml之后启动居然报错ERROR:transport error 202:bind failed:Address already,应该是远 ...
- Springboot集成ES启动报错
报错内容 None of the configured nodes are available elasticsearch.yml配置 cluster.name: fans node.name: no ...
- Idea启动报错 Error:java: System Java Compiler was not found in classpath
报错信息:Error:java: System Java Compiler was not found in classpath 使用IDEA启动的时候出现了这个错误,查找了很久,才找到解决办法 1. ...
随机推荐
- Java精通并发-锁升级与偏向锁深入解析
对于synchronized关键字,我们在实际使用时可能经常听说用它是一个非常重的操作,其实这个“重”是要针对JDK的版本来说的,如今JDK已经到了12版本了,其实对这个关键字一直是存在偏见的,它底层 ...
- LG4723 【模板】常系数线性递推
P4723 [模板]常系数齐次线性递推 题目描述 求一个满足$k$阶齐次线性递推数列${a_i}$的第$n$项. 即:$a_n=\sum\limits_{i=1}^{k}f_i \times a_{n ...
- 从零实现jQuery的extend
前言 jQuery 的 extend 是 jQuery 中应用非常多的一个函数,今天我们一边看 jQuery 的 extend 的特性,一边实现一个 extend! extend 基本用法 先来看看 ...
- nodejs查看本机hosts文件域名对应ip
const dns = require('dns') dns.lookup('domainName', function(err, result) { console.log(result) }) r ...
- Python中pass、continue、break、exit()的区别
pass :不做任何事情,只起到占位的作用 continue: 跳出本次循环 break:结束循环 exit():结束整个程序 由于continue和break较简单,这里就不给出代码
- 为何基于tcp协议的通信比基于udp协议的通信更可靠?
tcp协议一定是先建好双向链接,发一个数据包要得到确认才算发送完成,没有收到就一直给你重发:udp协议没有链接存在,udp直接丢数据,不管你有没有收到. TCP的可靠保证,是它的三次握手双向机制,这一 ...
- spark如何划分DAG视图
spark根据宽依赖进行DAG视图的划分. 1.窄依赖:每个父RDD的partition 最多被一个子RDD的 partition使用. 窄依赖分为两类:第一类是一对一的依赖关系,在Spark中用On ...
- 鼠标经过提高层级案例(margin,相对定位,z-index)
<body> <ul> <li class="box1">1</li> <li class="box2"& ...
- Maven+SSM整合ehcache
- Pytest权威教程23-不稳定测试
目录 不稳定测试用例处理 为什么不稳定测试是个问题 潜在的根本原因 Pytest特性 其他一般策略 相关研究 相关资源 返回: Pytest权威教程 不稳定测试用例处理 "不稳定" ...