应用程序在版本 2.2.6 下正常工作,但随着应用程序升级到最新版本的 spring boot 2.3.0,它停止工作并在启动过程中失败。
2020-05-20T08:43:04.408+01:00 [APP/PROC/WEB/0] [OUT] 2020-05-20 07:43:04.407 ERROR 15 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compositeMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/CompositeMeterRegistryConfiguration.class]: Unsatisfied dependency expressed through method 'compositeMeterRegistry' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'prometheusMeterRegistry' defined …
读取类路径资源,
try {
final ClassPathResource classPathResource = new ClassPathResource(format("location%sGeoLite2-City.mmdb", File.separator));
final File database = classPathResource.getFile();
dbReader = new DatabaseReader.Builder(database).build();
} catch (Exception e) {
System.out.println("Exception: " + e);
}
Run Code Online (Sandbox Code Playgroud)
我已经使用以下 Dockerfile 将它与 docker 打包在一起,
FROM java:8
ADD build/libs/*.jar App.jar
CMD java -jar App.jar
Run Code Online (Sandbox Code Playgroud)
但是在以docker run -p 8080:8080 app-image运行此应用程序时,我可以访问应用程序端点,并且从应用程序日志中我可以看到它无法读取此文件(以下来自日志),
Exception: java.io.FileNotFoundException: class path resource [location/GeoLite2-City.mmdb] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/App.jar!/BOOT-INF/classes!/location/GeoLite2-City.mmdb
Run Code Online (Sandbox Code Playgroud)
感谢您的任何评论,在您发表评论之前要了解的事情,
**- 在 windows 10、intellij 2018.2、jdk 8 …