现象描述:

spring boot 在eclipse里启动正常,但打包后启动不起来。

错误日志如下:

D:\Project>java -jar MKKY_CMS.jar.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::        (v2.1.4.RELEASE)2019-06-12 17:26:15.510  INFO 74468 --- [           main] com.mkky.SuperviseBackstageApplication   : Starting SuperviseBackstageApplication v0.0.1-SNAPSHOT on DESKTOP-405G2C8 with PID 74468 (D:\Project\MKKY_CMS.jar started by dell in D:\Project)
2019-06-12 17:26:15.513  INFO 74468 --- [           main] com.mkky.SuperviseBackstageApplication   : The following profiles are active: dev
2019-06-12 17:26:16.049  WARN 74468 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.mkky.SuperviseBackstageApplication]; nested exception is java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration
2019-06-12 17:26:16.059  INFO 74468 --- [           main] ConditionEvaluationReportLoggingListener :Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-12 17:26:16.065 ERROR 74468 --- [           main] o.s.boot.SpringApplication               : Application run failedorg.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.mkky.SuperviseBackstageApplication]; nested exception is java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfigurationat org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:599) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser.access$900(ConfigurationClassParser.java:108) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:808) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at java.util.ArrayList.forEach(ArrayList.java:1249) ~[na:1.8.0_91]at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:804) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:774) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at com.mkky.SuperviseBackstageApplication.main(SuperviseBackstageApplication.java:16) [classes!/:0.0.1-SNAPSHOT]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [MKKY_CMS.jar:0.0.1-SNAPSHOT]at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [MKKY_CMS.jar:0.0.1-SNAPSHOT]at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [MKKY_CMS.jar:0.0.1-SNAPSHOT]at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:593) [MKKY_CMS.jar:0.0.1-SNAPSHOT]
Caused by: java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfigurationat org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:218) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:361) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:263) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:589) ~[spring-context-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]... 27 common frames omitted
Caused by: java.lang.IllegalArgumentException: nameat sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:658) ~[na:1.8.0_91]at sun.misc.URLClassPath.findResource(URLClassPath.java:188) ~[na:1.8.0_91]at java.net.URLClassLoader$2.run(URLClassLoader.java:569) ~[na:1.8.0_91]at java.net.URLClassLoader$2.run(URLClassLoader.java:567) ~[na:1.8.0_91]at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_91]at java.net.URLClassLoader.findResource(URLClassLoader.java:566) ~[na:1.8.0_91]at org.springframework.boot.loader.LaunchedURLClassLoader.findResource(LaunchedURLClassLoader.java:57) ~[MKKY_CMS.jar:0.0.1-SNAPSHOT]at java.lang.ClassLoader.getResource(ClassLoader.java:1096) ~[na:1.8.0_91]at org.springframework.core.io.ClassPathResource.resolveURL(ClassPathResource.java:155) ~[spring-core-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.core.io.ClassPathResource.exists(ClassPathResource.java:142) ~[spring-core-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider.isTemplateAvailable(ThymeleafTemplateAvailabilityProvider.java:44) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders.findProvider(TemplateAvailabilityProviders.java:158) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders.getProvider(TemplateAvailabilityProviders.java:145) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$ErrorTemplateMissingCondition.getMatchOutcome(ErrorMvcAutoConfiguration.java:195) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]... 33 common frames omitted

问题解决路径

1. 最初怀疑是打包时缺少依赖包造成的,修改打包的方式

<build><finalName>xxxxx</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><fork>true</fork><mainClass>com.xx</mainClass><layout>ZIP</layout>     </configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build>

依赖包没有问题,还是报同样的错误。

2. 排除依赖包的问题后,怀疑是jar包冲突的问题,网上有类似的

https://stackoverflow.com/questions/32758000/java-lang-illegalstateexception-error-processing-condition-on-org-springframewo

使用dependence查了  没有不同版本的依赖,排除

3.怀疑是*config.java的配置问题,一个个移除进行测试,也排除掉了

4.根据日志怀疑是Controller里排除的异常页面有问题,排查后没有发现

5.怀疑是application_*.properties的配置问题

一项项排查,发现跟这个有关

spring.thymeleaf.prefix=static:/web/

去除这个选项后,重新打包后可以启动成功。

翻看源码ThymeleafProperties.java

/*** Properties for Thymeleaf.** @author Stephane Nicoll* @author Brian Clozel* @author Daniel Fern谩ndez* @author Kazuki Shimizu* @since 1.2.0*/
@ConfigurationProperties(prefix = "spring.thymeleaf")
public class ThymeleafProperties {private static final Charset DEFAULT_ENCODING = StandardCharsets.UTF_8;public static final String DEFAULT_PREFIX = "classpath:/templates/"; //1public static final String DEFAULT_SUFFIX = ".html";/*** Whether to check that the template exists before rendering it.*/private boolean checkTemplate = true;/*** Whether to check that the templates location exists.*/private boolean checkTemplateLocation = true;/*** Prefix that gets prepended to view names when building a URL.*/private String prefix = DEFAULT_PREFIX;/*** Suffix that gets appended to view names when building a URL.*/private String suffix = DEFAULT_SUFFIX;/*** Template mode to be applied to templates. See also Thymeleaf's TemplateMode enum.*/private String mode = "HTML";/*** Template files encoding.*/private Charset encoding = DEFAULT_ENCODING;/*** Whether to enable template caching.*/private boolean cache = true;/*** Order of the template resolver in the chain. By default, the template resolver is* first in the chain. Order start at 1 and should only be set if you have defined* additional "TemplateResolver" beans.*/private Integer templateResolverOrder;/*** Comma-separated list of view names (patterns allowed) that can be resolved.*/private String[] viewNames;/*** Comma-separated list of view names (patterns allowed) that should be excluded from* resolution.*/private String[] excludedViewNames;/*** Enable the SpringEL compiler in SpringEL expressions.*/private boolean enableSpringElCompiler;/*** Whether hidden form inputs acting as markers for checkboxes should be rendered* before the checkbox element itself.*/private boolean renderHiddenMarkersBeforeCheckboxes = false;/*** Whether to enable Thymeleaf view resolution for Web frameworks.*/private boolean enabled = true;private final Servlet servlet = new Servlet();private final Reactive reactive = new Reactive();public boolean isEnabled() {return this.enabled;}public void setEnabled(boolean enabled) {this.enabled = enabled;}public boolean isCheckTemplate() {return this.checkTemplate;}public void setCheckTemplate(boolean checkTemplate) {this.checkTemplate = checkTemplate;}public boolean isCheckTemplateLocation() {return this.checkTemplateLocation;}public void setCheckTemplateLocation(boolean checkTemplateLocation) {this.checkTemplateLocation = checkTemplateLocation;}public String getPrefix() {return this.prefix;}public void setPrefix(String prefix) {this.prefix = prefix;}public String getSuffix() {return this.suffix;}public void setSuffix(String suffix) {this.suffix = suffix;}public String getMode() {return this.mode;}public void setMode(String mode) {this.mode = mode;}public Charset getEncoding() {return this.encoding;}public void setEncoding(Charset encoding) {this.encoding = encoding;}public boolean isCache() {return this.cache;}public void setCache(boolean cache) {this.cache = cache;}public Integer getTemplateResolverOrder() {return this.templateResolverOrder;}public void setTemplateResolverOrder(Integer templateResolverOrder) {this.templateResolverOrder = templateResolverOrder;}public String[] getExcludedViewNames() {return this.excludedViewNames;}public void setExcludedViewNames(String[] excludedViewNames) {this.excludedViewNames = excludedViewNames;}public String[] getViewNames() {return this.viewNames;}public void setViewNames(String[] viewNames) {this.viewNames = viewNames;}public boolean isEnableSpringElCompiler() {return this.enableSpringElCompiler;}public void setEnableSpringElCompiler(boolean enableSpringElCompiler) {this.enableSpringElCompiler = enableSpringElCompiler;}public boolean isRenderHiddenMarkersBeforeCheckboxes() {return this.renderHiddenMarkersBeforeCheckboxes;}public void setRenderHiddenMarkersBeforeCheckboxes(boolean renderHiddenMarkersBeforeCheckboxes) {this.renderHiddenMarkersBeforeCheckboxes = renderHiddenMarkersBeforeCheckboxes;}public Reactive getReactive() {return this.reactive;}public Servlet getServlet() {return this.servlet;}public static class Servlet {/*** Content-Type value written to HTTP responses.*/private MimeType contentType = MimeType.valueOf("text/html");/*** Whether Thymeleaf should start writing partial output as soon as possible or* buffer until template processing is finished.*/private boolean producePartialOutputWhileProcessing = true;public MimeType getContentType() {return this.contentType;}public void setContentType(MimeType contentType) {this.contentType = contentType;}public boolean isProducePartialOutputWhileProcessing() {return this.producePartialOutputWhileProcessing;}public void setProducePartialOutputWhileProcessing(boolean producePartialOutputWhileProcessing) {this.producePartialOutputWhileProcessing = producePartialOutputWhileProcessing;}}public static class Reactive {/*** Maximum size of data buffers used for writing to the response. Templates will* execute in CHUNKED mode by default if this is set.*/private DataSize maxChunkSize = DataSize.ofBytes(0);/*** Media types supported by the view technology.*/private List<MediaType> mediaTypes;/*** Comma-separated list of view names (patterns allowed) that should be executed* in FULL mode even if a max chunk size is set.*/private String[] fullModeViewNames;/*** Comma-separated list of view names (patterns allowed) that should be the only* ones executed in CHUNKED mode when a max chunk size is set.*/private String[] chunkedModeViewNames;public List<MediaType> getMediaTypes() {return this.mediaTypes;}public void setMediaTypes(List<MediaType> mediaTypes) {this.mediaTypes = mediaTypes;}public DataSize getMaxChunkSize() {return this.maxChunkSize;}public void setMaxChunkSize(DataSize maxChunkSize) {this.maxChunkSize = maxChunkSize;}public String[] getFullModeViewNames() {return this.fullModeViewNames;}public void setFullModeViewNames(String[] fullModeViewNames) {this.fullModeViewNames = fullModeViewNames;}public String[] getChunkedModeViewNames() {return this.chunkedModeViewNames;}public void setChunkedModeViewNames(String[] chunkedModeViewNames) {this.chunkedModeViewNames = chunkedModeViewNames;}}}

配置前缀的路径有问题。

转载于:https://www.cnblogs.com/davidwang456/p/11011390.html

spring boot 在eclipse里启动正常,但打包后启动不起来相关推荐

  1. Spring Boot(号称Java当前最流行的开发框架) 中启动HTTPS

    Spring Boot(号称Java当前最流行的开发框架) 中启动HTTPS 说实话啊,这个框架是比较简单,但是数据库操作还是那么恶心,好比16岁的花姑娘配了一个80岁的老头,关于这一块,我会单独发布 ...

  2. electron 打包后启动应用报错:Error: ENOENT: no such file or directory, open ‘xxx/manifest.json‘‘

    使用 electron-builder 打包后启动报错: Reading /xxx/manifest.json failed. Error: ENOENT: no such file or direc ...

  3. Spring Boot 2.2 增加了一个新功能,启动飞起~

    前几天栈长分享了一个好玩的框架:一个比Spring Boot快44倍的Java框架!,是不是感觉 Spring Boot 略慢?今天讲一下 Spring Boot 添加的这个新特性,可以大大提升 Sp ...

  4. 精选10个用于Java开发Spring Boot的Eclipse插件

    前言 作为从事Java多年的程序员,在此分享用于 Java 和 Spring Boot 开发的 10 大 Eclipse插件: 1. EGit - Eclipse 的 Git 集成 这可能是当今 Ja ...

  5. Spring Boot 多模块项目实践(附打包方法)

    序言:比起传统复杂的单体工程,使用Maven的多模块配置,可以帮助项目划分模块,鼓励重用,防止POM变得过于庞大,方便某个模块的构建,而不用每次都构建整个项目,并且使得针对某个模块的特殊控制更为方便. ...

  6. spring boot 单元测试_spring-boot-plus1.2.0-RELEASE发布-快速打包-极速部署-在线演示

    spring-boot-plus spring-boot-plus 集成spring boot常用开发组件的后台快速开发脚手架 Purpose 每个人都可以独立.快速.高效地开发项目! Everyon ...

  7. 最细致的Spring Boot结合Vue前后端分离项目打包部署步骤(搭配Nginx)

    文章目录 前言 一.环境准备 二.SpringBoot项目打jar包 1.1 使用Maven的package插件打包 1.2 上传至Linux服务器 三.Vue项目打包 1.1 修改后台请求地址 1. ...

  8. Spring Boot基础学习笔记16:项目打包部署

    文章目录 零.学习目标 一.Web项目打包部署概述 二.Jar包方式打包部署 (一)添加Maven打包插件 (二)使用IDEA进行打包 (三)Jar包目录结构说明 (四)Jar包方式部署 1.在控制台 ...

  9. 普元 AppServer 6.5 哑安装后执行启动命令./startup.sh后启动失败

    [问题] AppServer 6.5 哑安装后执行启动命令后启动失败,见下图: [解答] 原因:执行启动命令时,直接在安装包:Primeton_AppServer_6.5_Enterprise_Edi ...

最新文章

  1. PHP上传文件缺省目录,帝国cms默认图片、附件上传路径/d/file/怎么修改
  2. 第10章 嵌入式linux的调试技术
  3. java开关用法_如何在Java中使用带开关盒的枚举?
  4. 转载:vscode快捷键
  5. 鸿蒙 电视 安卓,华为鸿蒙2.0、EMUI 11齐发 打通手机、电视、PC全平台
  6. java web微服务是什么_java微服务是什么
  7. hive性能优化指南
  8. deactivate_sending在创建新的table entry时的作用
  9. Linux网络编程一步一步学-select详解
  10. Swift标识符和关键字
  11. 网络安装archlinux(2012.8.20)笔记
  12. 查询公司资产数据库中的主机是否在zabbix的监控中
  13. MySQL优化详解(二)——数据库架构和使用优化
  14. 附录B. Design Motivations【设计意图】
  15. 简单的网页在线咨询代码
  16. vr课设《梵高世界》第一人称的解谜游戏
  17. bluehost中国和bluehost美国的区别?应该选择哪个?
  18. 我喜欢计算机作文300字,关于我喜欢作文300字
  19. 谷粒商城笔记+踩坑(18)——购物车
  20. 360WIFI登陆页面地址

热门文章

  1. TACACS 协议简介与开发总结
  2. 安卓实现定位功能的4种方式
  3. 开服侠显示服务器已停止,蜘蛛侠:极限(已关服)无法连接服务器是什么原因...
  4. oracle中批量更新,oracle 批量更新
  5. 用mysql随机查询表a10条数据_ES简介
  6. python实现列表去重_python实现七种列表去重方法
  7. java窗口如何写不能移动_[求助]请教高手,下面程序为何组件不能自由移动,百思不得其解!...
  8. pandas的str函数的一些功能
  9. Android短信拦截2019,关于征集2019年度信息科学领域重大项目立项建议的通告
  10. python pip 安装与使用_Python pip 安装与使用(安装、更新、删除)