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. ...
随机推荐
- Kibana<6.6.0代码执行漏洞复现
更多内容,欢迎关注微信公众号:信Yang安全,期待与您相遇. 使用docker快速部署环境docker pull kibana:6.5.4docker pull elasticsearch:6.5.4 ...
- laravel-nestedset:多级无限分类正确姿势
laravel-nestedset:多级无限分类正确姿势 laravel-nestedset是一个关系型数据库遍历树的larvel4-5的插件包 目录: Nested Sets Model简介 安 ...
- greenplum 下载地址
一.推荐使用下面下载地址 https://network.pivotal.io/products/pivotal-gpdb#/releases/158026/file_groups/1083 二.官网 ...
- web场景的监控
在一台可以连外网的主机上创建web场景, 添加步骤,zabbix可以步骤化web页面,例如,登陆操作,正常操作是要先验证用户获取token,step1就可以是先访问token页面,获取到返回的toke ...
- Kindle Touch 修砖手札
首先是网上的修砖教程: 最近有多人反映按照修砖程序走过后依然板砖,和碎平联系和WA沟通后对帖子作新的修改. 新教程直接使用5.1.2的镜像,特别说明. 特别感谢kn007的专业指导 小白帖子现为简化过 ...
- CODE FESTIVAL 2016 qual B题解
传送门 \(A\) 什么玩意儿-- const char t[]={"0CODEFESTIVAL2016"}; char s[25];int res; int main(){ sc ...
- (2)Angular的开发
什么是 ReactNative应用, 小程序与RN的关系 native端优化 Js端优化 ReactNative是? 用JavaScript来写App,性能好 异步编程 请点赞!因为你的鼓励是我写作的 ...
- UOJ272. 【清华集训2016】石家庄的工人阶级队伍比较坚强 [FWT]
UOJ 思路 很容易想到\(O(3^{3m}\log T)\)的暴力大矩乘,显然过不了. 我们分析一下每次转移的性质.题目给的转移方程是填表法,我们试着改成刷表法看看-- 发现好像没啥用. 注意到游戏 ...
- Java 操作Redis封装RedisTemplate工具类
package com.example.redisdistlock.util; import org.springframework.beans.factory.annotation.Autowire ...
- SpaceClaim脚本功能(Beta功能)
本操作仅适用ANSYS SpaceClaim 2016 打开SpaceClaim脚本编辑器的方法有两种 方法一(看截图操作): 方法二(请见后面的实例操作). 创建球体源代码: #定义 ...