最近碰到了一个棘手的问题,
一个 spring boot 工程,打包成可执行的 fat jar。jar包没有问题,在各个环境都运行正常。但是唯独在其中一个服务器上启动会报错,而且,更诡异的是,当前目录在 /shell 目录,jar包正常启动,切换到其他目录才会报错。
下面是启动报错的情况下输出的日志,加了 -Dloader.debug=true ,可以看到加载的一些细节。
Trying classpath: /BOOT-INF/classes/application.properties
Not found: classpath:BOOT-INF/classes/application.properties
Property 'loader.path' from environment: /data/application/xxx/xxx-batch-new/conf
Nested archive paths: [/data/application/xxx/xxx-batch-new/conf/]
Property 'Loader-Args' from home directory manifest: null
Adding classpath entries from /data/application/xxx/xxx-batch-new/conf
Property 'Loader-ClassLoader' from home directory manifest: null
Property 'Start-Class' from home directory manifest: null
Exception in thread "main" java.lang.IllegalStateException: No 'loader.main' or 'Start-Class' specified
at org.springframework.boot.loader.PropertiesLauncher.getMainClass(PropertiesLauncher.java:317)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:521)
这里是正常启动的时候输出的日志,虽然有明显的差别,但是,毕竟是个运维,翻了半天 spring boot的源码,仍然没找到真正的原因。还希望大家多指点指点。
Trying classpath: /BOOT-INF/classes/application.properties
Not found: classpath:BOOT-INF/classes/application.properties
Property 'loader.path' from environment: /data/application/xxx/xxx-batch-new/conf
Nested archive paths: [/data/application/xxx/xxx-batch-new/conf/]
Property 'Start-Class' from archive manifest: com.xxx.xxx.BatchApplication