在尝试启动现有的Gradle项目上的Spring Boot应用程序时出现错误。

huangapple go评论77阅读模式
英文:

Getting error while trying to start springboot application on existing gradle project

问题

我从 Git 克隆了项目,但当我运行应用程序类时,出现了以下错误:

使用来自 'classpath:logback-spring.xml' 的配置初始化日志系统时出错
java.lang.IllegalStateException: 检测到 Logback 配置错误:
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[rollingfileSync] - 无法为 [/opt/apps/aggregator/api/logs/Duke-service.log] 创建父目录
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[rollingfileSync] - 打开文件(/opt/apps/aggregator/api/logs/Duke-service.log,true) 失败。 java.io.FileNotFoundException: /opt/apps/aggregator/api/logs/Duke-service.log(没有该文件或目录)
	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               : 应用程序运行失败
英文:

I have cloned project from Git, but when I run the application class I get this error.

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

答案1

得分: 0

从日志中看,用户(通过该用户登录,例如 abhishek)似乎没有权限创建目录 /opt/apps/aggregator/api/logs

所以首先确保运行 Springboot 服务器的用户(abhishek)有权限创建该目录。

您可以通过在(/opt/、/opt/apps/ 和子目录,如果它们已经存在)中执行 ls -ltra 来检查这一点。

例如:

-rw-r--r-- 1 raviy raviy 655 Feb 25 2019 .profile
-rw-r--r-- 1 raviy raviy 220 Feb 25 2019 .bash_logout

这里 raviy 是所有者,如果您不是所有者,则更改权限(使用 sudo 或询问管理员)。

chmod -R 777 /opt(应避免使用 777,这只是为了运行程序)

之后 Java 应该能够创建该目录。

英文:

From logs it seems the User (through which you are logged in e.g. abhishek) dont have permission to create the directory /opt/apps/aggregator/api/logs

So first make sure that the User who is running the Springboot server (abhishek) has permission to create the dir.

This you can check by doing ls -ltra in ( /opt/, /opt/apps/ and sub dir if they are already existing)

e.g.

-rw-r--r-- 1 raviy raviy 655 Feb 25 2019 .profile
-rw-r--r-- 1 raviy raviy 220 Feb 25 2019 .bash_logout

Here raviy is owner, if you are not owner then change permission(with sudo or ask admin)

chmod -R 777 /opt ( 777 should be avoided, its hustto run your program)

after that java should be able to create the dir

huangapple
  • 本文由 发表于 2020年8月21日 12:14:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/63516432.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定