🔥
Caster 開發日誌
  • Java
    • JVM Performance Tool
      • Java Debug Wire Protocol (JDWP) 的詳細介紹
      • JConsole 詳細介紹
    • Spring Boot
      • Spring Security
      • Spring Boot Admin
      • Spring Event
      • Spring AOP
      • Spring Boot JUnit 5
      • Apache Dubbo
    • Reflect 應用
    • ELK + F 建構
    • Socket.IO
    • OCR - 光學字元辨識
    • 讀取JAR resource文件
    • LocalTime & MySQL時間精度
    • Gradle multi module
    • MyBatis-Plus
    • Java Date operation
    • Java IP to Long
    • Apache Commons lang3 應用
      • Function 應用
    • Cloud Platform
      • Amazon S3
        • SDK V1
          • Bucket
        • SDK V2
          • Bucket
      • Google Cloud Platform
      • Azure Cloud
        • Storage
      • OVHcloud
        • Config
    • SSL/TLS工具
    • Util 工具
      • Jackson Json工具
      • Charles應用
      • JMeter – Performing Distributed Load Testing with Docker
    • Redis
      • Stream
      • Redisson 分布式鎖機制
      • Create Redis Cluster Using Docker
      • List Operations
    • Java 8
      • method & constructor Reference
      • CompletableFuture
      • FunctionInterface
      • Stream 應用
      • 繁簡轉換 - 簡易調整
    • MySQL
      • 建立測試用 流水號Table
      • SQL 效能調校 - Explain
      • SQL 效能調校 - Partition
      • 排程 - Event
    • Apache ShardingSphere
  • Kubernetes
    • 初入江湖(K8S)
    • 零中斷服務滾動更新
    • Kubernetes DNS
    • Ingress & Ingress Controller 教學
    • Ingress TLS Easy setup
  • 指令集
  • Telegram
  • SourceTree
    • 踩坑紀錄(ㄧ) - Git Flow
    • 踩坑紀錄(二) - 修改檔名
  • 專案統計
    • Robot
    • Recharge
  • GitHub
    • Actions
  • GitLab
    • 介紹 GitLab
    • 使用 Docker 自架 GitLab
    • 簡介 GitLab CI/CD
      • GitLab Runner 詳細介紹與設定方式
Powered by GitBook
On this page
  1. Java

讀取JAR resource文件

在以SpringBoot Base 專案, 使用multi module時, 當要讀取commons module文件, 路徑的排錯經歷.

PreviousOCR - 光學字元辨識NextLocalTime & MySQL時間精度

Last updated 1 year ago

此次測試範例專案架構

問題及分析

SRestapi 打包後, 啟動時報錯找不到 GeoLite2-Country.mmdb 這個檔案.

2022-06-09 15:59:29.944 [main] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'fetchGeoLiteDatabaseReader'
java.io.FileNotFoundException: class path resource [GeoLite2-Country.mmdb] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/Users/caster/Documents/workplace/splatform/S_Restapi/build/libs/SPlatform_Restapi.jar!/BOOT-INF/lib/S_Core-0.0.1-SNAPSHOT-plain.jar!/GeoLite2-Country.mmdb
        at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:217)
        at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:162)
        at com.longxiang.config.CommonConfig.fetchGeoLiteDatabaseReader(CommonConfig.java:40)
        at com.longxiang.config.CommonConfig$$EnhancerBySpringCGLIB$$47c48ffc.CGLIB$fetchGeoLiteDatabaseReader$1(<generated>)
        at com.longxiang.config.CommonConfig$$EnhancerBySpringCGLIB$$47c48ffc$$FastClassBySpringCGLIB$$40fa806d.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)

但是去把SRestapi打包的Jar, 找得到這個檔案但為什麼會讀取不到呢? 待補詳細原因先附上最後解決方式

SRestapi dependencies S_Core
final