spring boot war部署及遇到的異常問題(不帶web.xml)
SpringBoot 打包成war包部署到tomcat(不帶 web.xml檔案 servlet3.0及之後可以不用配置)
在用idea 搭建 spring boot 並打包釋出到外部tomcat部署,原本以為很簡單的事情,沒想到還是遇到了一些異常情況,
找了好多資料都沒有解決問題,今天無意中找到一個方案搞定了,隨寫下用以記錄
途中遇到的異常:
1.因為最簡單的demo所以沒有用到相關的事物,因此需要在啟動類裡移除TransactionAutoConfiguration 類
這種錯誤一般是因為載入了元件,但是沒有正確配置,這也就可以通過 exclude 移除掉
如果出現 DataSourceAutoConfiguration 相關的錯誤 也可以直接移除
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration$EnableTransactionManagementConfiguration$CglibAutoProxyConfiguration]; nested exception is java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:296) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:241) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] 07-Mar-2018 11:29:39.675 嚴重 [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:355) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:261) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:241) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
附帶. pom.xml 配置檔案
<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>--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build>
. application 啟動類
@SpringBootApplication @EnableAutoConfiguration(exclude = {TransactionAutoConfiguration.class, DataSourceAutoConfiguration.class}) public class ChatApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(ChatApplication.class); } public static void main(String[] args) { SpringApplication.run(ChatApplication.class, args); } }
相關推薦
spring boot war部署及遇到的異常問題(不帶web.xml)
SpringBoot 打包成war包部署到tomcat(不帶 web.xml檔案 servlet3.0及之後可以不用配置)在用idea 搭建 spring boot 並打包釋出到外部tomcat部署,原本以為很簡單的事情,沒想到還是遇到了一些異常情況,找了好多資料都沒有解決問
Spring boot war 部署外部tomcat
網上各種說法都有,結果都不行,拜讀了一下Sprint boot2 精髓中提供的部署方式,發現也是很坑爹,根本不起作用,最後自己各種測試終於搞定,在此記錄: 總共四個步驟: 1. 修改pom.xml <packaging>war</
spring boot mongodb 整合以及簡單查詢(非實體結果返回)
一、安裝(nosql 視覺化工具客戶端下載路徑:https://nosqlbooster.com/downloads) 二、專案新增依賴 <dependency> <groupId>org.springframework.boot</groupId>
Spring boot + shiro + redis 實現session共享(偽單點登入)
為實現Web應用的分散式叢集部署,要解決登入session的統一。本文利用shiro做許可權控制,redis做session儲存,結合spring boot快速配置實現session共享。注意本文未解決跨域的問題。不過對於一般的情況能夠很好的起到作用,具體已經在不同埠
spring boot熱部署,修改java程式碼不重啟
我用的idea外掛,雖然每次用虛擬機器重啟快很多,但是每次看到有日誌列印專案重啟感覺還是不舒服。所以部署了不重啟的方法 首先和其他的類似,idea中的配置 registry 勾選 compiler.automake.allow.when.app.running 然後
純Java啟動Web(無配置web.xml)
純Java啟動Web(無配置web.xml) 前言 突然奇想不用SpringBoot,並且不配置xml檔案來啟動Web應用程式! 正文 先貼出程式所需的Java程式碼以及Pom,如下: Pom.xml <?xml v
truncate、delete(不帶where子句)與drop的區別
truncate、delete(不帶where子句)與drop的異同點: 相同之處: 三者均會刪除表內的data。 不同點: <1>、truncate與不帶where的delete :只刪除資料,而不刪除表的結構(定義) drop語句將刪除表
題15:全排列(不帶重複元素)
題目描述: 給定一個數字列表,返回其所有可能的排列。 例如: 給出一個列表[1,2,3],其全排列為: [ [1, 2, 3], [1, 3, 2], [2, 1, 3]
spring boot 用war包部署到tomcat下詳細教程(解決缺少web.xml報錯的問題)
1.首先 修改pom.xml下的打包方式 <packaging>war</packaging> 2.新增servlet-api依賴 <!--新增servlet-api的依賴--> <dependency> <gr
spring boot 1.5.4 統一異常處理(九)
springboot springboot1.5.4 springboot整合springdatajpa springboot集成jdbctemplate springboot異常處理 上一篇:springboot 1.5.4 配置文件詳解(八) 1 Spring Boot統一異
Spring Boot速覽及在Azure上的部署
Azure 微軟 Spring Boot Java 雲 Spring Boot繼承了Spring Framework的強大,但卻同時免去了Spring Framework繁雜的配置,而且其內置TomCat容器,使得web開發極為高效便捷。此外,隨著與雲計算,集群等技術的成本不斷下降並變得廣
Spring Boot-錯誤處理及自定義全域性異常處理機制
正常的Web應用開發時,需要考慮到應用執行發生異常時或出現錯誤時如何來被處理,例如捕獲必要的異常資訊,記錄日誌方便日後排錯,友好的使用者響應輸出等等。 當然應用發生錯誤,有可能是應用自身的問題,也有可能是客戶端操作的問題。 Spring Boot預設提供了一種錯誤處理機制。 預設錯誤處理機制
spring boot 專案 部署 日誌 配置 及啟動
liunx 系統 啟動 spring boot 專案 nohup java -jar my-spring-boot.jar --spring.profiles.active=prod --spring.profiles.active=prod 指的是生產環境 n
Spring Boot 整合Mybatis 之 Mapper外掛(自動生成XML及Mapper程式碼)
pom檔案 主要程式碼 <dependencies> <dependency> <groupId>mysql</groupId> <artifactI
Spring boot+Security OAuth2 爬坑日記(4)自定義異常處理 上
為了方便與前端更好的互動,服務端要提供友好統一的資訊返回格式,(他好我也好 ->_-> ),Spring Security OAuth2 提供了自定義異常的入口;我們需要做的就是實現對應的介面,然後將實現的類配置到對應的入口即可。預設的資訊返回格式
(3)Spring Boot熱部署【從零開始學Spring Boot】
在編寫程式碼的時候,你會發現我們只是簡單把列印資訊改變了下,就需要重新部署,如果是這樣的編碼方式,那麼我們估計一天下來之後就真的是打幾個Hello World之後就下班了。那麼如何解決熱部署的問題呢?那就是springloaded,加入如下配置: <plugin>
idea spring boot 熱部署 (真正的不需要重啟)Jrebel License 免費啟用Jrebel
IDEA版本 2017.2.4 Jrebel 版本7.1.61、開啟idea自動make功能 2、CTRL + SHIFT + A --> 查詢Registry --> 找到並勾選compiler.automake.allow.when.app.running
Spring Boot文件上傳示例(Ajax和REST)
模型 custom rop null nds con and 程序 docs 本文介紹如何使用Ajax請求在Spring Boot Web應用程序(REST結構)中上傳文件。 本文中使用的工具: Spring Boot 1.4.3.RELEASE Spring 4.3.5
Jenkins spring boot 自動部署方案
微服務 技術 部署 com 中小型 手動 ges 進行 結果 原文地址:http://www.cnblogs.com/skyblog/p/5632869.html 現在主流的自動部署方案大都是基於Docker的了,但傳統的自動部署方案比較適合中小型公司,下面的方案就是比較
Spring Boot使用thymeleaf模板時報異常:template might not exist or might not be accessible by any of the configured Template Resolvers
logs pla 開頭 spring 方法 temp ring mode acc 錯誤如下: template might not exist or might not be accessible by any of the configured Template R