最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【未解决】Java的SpringBoot的jar解压后用JarLauncher启动报错:log4j2.xml No such file or directory

file crifan 53浏览 0评论
折腾:
【未解决】把Mac本地的SpringBoot的Java服务部署上传到远程服务器CentOS中
期间,参考:
Deploying Spring Boot Applications
去解压了SpringBoot的jar后,去启动,结果报错:
 java org.springframework.boot.loader.JarLauncher
Logging system failed to initialize using configuration from 'src/main/resources/log4j2.xml'
java.io.FileNotFoundException: /Users/crifan/dev/dev_root/projects/xxx/src/server/xxx/xxx/target/src/main/resources/log4j2.xml (No such file or directory)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(FileInputStream.java:195)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at java.io.FileInputStream.<init>(FileInputStream.java:93)
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
        at java.net.URL.openStream(URL.java:1045)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:317)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:288)
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
        at com.crifan.xxx.AccessingDataMysqlApplication.main(AccessingDataMysqlApplication.java:12)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
2020-03-27 21:08:28,220 ERROR SpringApplication.java:826 - Application run failed
java.lang.IllegalStateException: java.io.FileNotFoundException: /Users/crifan/dev/dev_root/projects/xxx/src/server/xxx/xxx/target/src/main/resources/log4j2.xml (No such file or directory)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:324) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:288) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        at com.crifan.xxx.AccessingDataMysqlApplication.main(AccessingDataMysqlApplication.java:12) [classes/:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [target/:?]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [target/:?]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [target/:?]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [target/:?]
Caused by: java.io.FileNotFoundException: /Users/crifan/dev/dev_root/projects/xxx/src/server/xxx/xxx/target/src/main/resources/log4j2.xml (No such file or directory)
        at java.io.FileInputStream.open0(Native Method) ~[?:1.8.0_112]
        at java.io.FileInputStream.open(FileInputStream.java:195) ~[?:1.8.0_112]
        at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[?:1.8.0_112]
        at java.io.FileInputStream.<init>(FileInputStream.java:93) ~[?:1.8.0_112]
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90) ~[?:1.8.0_112]
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188) ~[?:1.8.0_112]
        at java.net.URL.openStream(URL.java:1045) ~[?:1.8.0_112]
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:317) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
        ... 22 more
springboot log4j2.xml No such file or directory
springboot JarLauncher log4j2.xml No such file or directory
java – spring-boot application stops when logging.config points to incorrect file location for logfj2 external configuartion file – Stack Overflow
Spring Log4j2 xml file location – Stack Overflow
Spring Boot – no log file written (logging.file is not respected) – Stack Overflow
Spring Profiles, different Log4j2 configs – Stack Overflow
java JarLauncher log4j2.xml No such file or directory
Application fails to start and logs nothing when logback-spring.xml is malformed · Issue #10711 · spring-projects/spring-boot
注意到:
src/server/xxx/xxx/src/main/resources/application.properties
logging.config=src/main/resources/log4j2.xml
配置写了此处位置,但是对应此处却没有该配置文件
所以报错。
java – How to define log4j2 path by application.properties? – Stack Overflow
算了,暂时懒得解决这个问题了:
毕竟是SpringBoot的jar的解压后的问题,一般很难遇到,不紧急,抽空再去解决。

转载请注明:在路上 » 【未解决】Java的SpringBoot的jar解压后用JarLauncher启动报错:log4j2.xml No such file or directory

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
19 queries in 0.080 seconds, using 9.48MB memory