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
搞定!
================================华丽的分割线====================================
但是,强烈不建议使用SpringBoot发布war包,原因有三:
1、默认的SpringBoot支持静态资源以jar包的方式发布部署
2、前后端分离,后端使用SpringBoot开发,前段就无所谓了,完全可以不依赖SpringBoot
3、在服务端加入Swagger插件,直接通过接口做测试,无需web界面

参考:
spring boot 用war包部署到tomcat下详细教程
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: 问题原因: ...
- 008-SpringBoot发布WAR启动报错:Error assembling WAR: webxml attribute is required
一.Spring Boot发布war包流程: 1.修改web model的pom.xml <packaging>war</packaging> SpringBoot默认发布的都 ...
- 【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 ...
- 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 ...
- 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. ...
随机推荐
- oracle count(*) 和count(列)性能
一直以为oracle中count(列)比count(*) 快,这篇文件解释了一下: http://blog.csdn.net/szstephenzhou/article/details/8446481
- Readthedocs+Github搭建文档
一.文档撰写前提 环境部署: > git clone https://github.com/toooney/demo-readthedocs.git > pip install sphin ...
- 百度Echart 地图
使用百度地图做一个全国地图数据分析的功能,如下图 代码 <%@ Page Language="C#" AutoEventWireup="true" Cod ...
- Android NDK开发 图片处理(五)
做过Java的同学可能经常会遇到一些关于图片处理的 例如类似QQ离线头像显示灰的.最快的算法是用colorMatrix来实现.这里通过Java调用JNI来处理每一个像素来实现. 对每一个像素点取出RG ...
- 支付宝php支付接口说明
直接把该代码放到PHP服务器下,直接访问index.php.1.文件列表: alipay_config.php (基本参数配置页面,填写商家的支付宝安全校验码,合作id,支付宝帐号等内容)ind ...
- JEECMS站群管理系统-- 自定义标签及使用自己创建的表的实现过程
下面是我自己定义的标签mycontent_list 首先,在数据库里创建了一个jc_mycontent的表,其中有id,title,content三个字段 其次,创建了一个实体类 public cla ...
- Tips In C
C语言中的使用操作 宏定义时使用do while防止语句的分离, 但是不使用与需要有返回值的语句, 这个时候可以参考第二条 宏定义时使用({}), ()加上{}的方式, 在代码中填写逻辑算法, 最后的 ...
- URAL 1145—— Rope in the Labyrinth——————【求树的直径】
Rope in the Labyrinth Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64 ...
- sass基础2
- Lombok使用与问题
前言 想想已经工作了一年,工作中遇到的问题一直没有记录下来,以后遇到相同的问题可能还需要花费很多的时间,因此打算记录一下博客.方便以后自己的复习和问题查找 刚好最近项目引入了Lombok,刚好从现在起 ...