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. ...
随机推荐
- 超全整理!Linux shell及常用36类命令汇总
本文采编自http://blog.csdn.net,作者为ZHXGXN,版权归作者所有! 使用Linux shell是一些程序员每天的基本工作,但我们经常会忘记一些有用的shell命令和技巧.当然,命 ...
- 华硕ASUS U5800GE驱动
重要的触摸板 微软商店 ASUS Keyboard Hotkeys 设备管理器 人体学输入设备 ASUS Precision Touchpad (ScreenPad) Asus ScreenPad D ...
- Java - Oscache 缓存
1. web.xml 文件配置 <!-- 配置页面缓存 --> <filter> <filter-name>oscache</filter-name> ...
- dede5.7评论框不显示,文章页表情不显示,解决办法
dede5.7评论框不显示,文章页表情不显示,解决办法 进入dede后台,系统-系统基本参数-其它选项,找到模板引擎禁用标签,去掉里面的php,如图 进入dede模板目录,默认是/templets/d ...
- Stone Game II
Description There is a stone game.At the beginning of the game the player picks n piles of stones in ...
- Kubernetes 学习14 kubernetes statefulset
一.概述 1.在应用程序中我们有两类,一种是有状态一种是无状态.此前一直演示的是deployment管理的应用,比如nginx或者我们自己定义的myapp它们都属于无状态应用. 2.而对于有状态应用, ...
- 02_SAE中创建数据表
Step1:进入新浪云应用数据库点击应用名称,进入到该应用管理界面,在数据库服务中点击“共享型MySQL”: 开启MySQL服务,使用PHPMyAdmin管理数据库,进入MySQL数据库管理界面: S ...
- 018_Python3 模块
在前面的几个章节中我们脚本上是用 python 解释器来编程,如果你从 Python 解释器退出再进入,那么你定义的所有的方法和变量就都消失了. 为此 Python 提供了一个办法,把这些定义存放在文 ...
- learning java 获取环境变量及系统属性
通过System.getenv( ) 获取环境变量 通过System.getProperties() 获取系统属情 通过System.currentTimeMillis() System.nanoT ...
- P1168 中位数(线段树)
题目描述 给出一个长度为N的非负整数序列A[i],对于所有1 ≤ k ≤ (N + 1) / 2,输出A[1], A[3], …, A[2k - 1]的中位数.即前1,3,5,……个数的中位数. 输入 ...