我已经从Git克隆了项目,但是在运行应用程序类时出现此错误。
Logging system failed to initialize using configuration from 'classpath:logback-spring.xml'
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[rollingfileSync] - Failed to create parent directories for [/opt/apps/aggregator/api/logs/Duke-service.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[rollingfileSync] - openFile(/opt/apps/aggregator/api/logs/Duke-service.log,true) call failed. java.io.FileNotFoundException: /opt/apps/aggregator/api/logs/Duke-service.log (No such file or directory)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:67)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:57)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:117)
at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:298)
at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:266)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:229)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:202)
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:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at Application.main(Application.java:26)
2020-08-21 09:35:31.400 ERROR 21323 --- [ main] o.s.boot.SpringApplication : Application run failed
最佳答案
从日志看来,用户(您通过其登录例如abhishek)似乎没有权限创建目录/ opt / apps / aggregator / api / logs
因此,首先请确保运行Springboot服务器(abhishek)的用户具有创建目录的权限。
您可以通过在/ opt /,/ opt / apps /和sub dir中执行ls -ltra进行检查(如果它们已经存在)
例如
-rw-r--r-- 1 raviy raviy 655二月25 2019 .profile
-rw-r--r-- 1 raviy raviy 220 2019年2月25日.bash_logout
这里raviy是所有者,如果您不是所有者,则更改权限(使用sudo或Ask admin)
chmod -R 777 / opt(应避免使用777,它必须运行您的程序)
之后,java应该能够创建目录