{"id":16179261,"url":"https://github.com/jonashackt/springbootreadfilejar","last_synced_at":"2025-04-07T11:43:29.832Z","repository":{"id":35305163,"uuid":"39566492","full_name":"jonashackt/springbootreadfilejar","owner":"jonashackt","description":"Demo project for reading Files from within Spring Boot Fat-jar with Java NIO.2","archived":false,"fork":false,"pushed_at":"2015-07-23T13:53:05.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T14:24:20.063Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonashackt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-23T12:37:22.000Z","updated_at":"2015-07-23T13:35:31.000Z","dependencies_parsed_at":"2022-09-17T00:51:47.262Z","dependency_job_id":null,"html_url":"https://github.com/jonashackt/springbootreadfilejar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fspringbootreadfilejar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fspringbootreadfilejar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fspringbootreadfilejar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fspringbootreadfilejar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonashackt","download_url":"https://codeload.github.com/jonashackt/springbootreadfilejar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648923,"owners_count":20972942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T05:26:28.529Z","updated_at":"2025-04-07T11:43:29.707Z","avatar_url":"https://github.com/jonashackt.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# springbootreadfilejar\nDemo project for reading Files from within Spring Boot Fat-jar with Java NIO.2\n\n### Wait, what??!\nThere is an [Issue] with loading Files inside of a SpringBoot Fatjar with Java NIO.2 Files and especially Paths.get()-Methode, which is needed to use Files. [Oracle] has something for ya.\n\n### HowTo\nRun it inside of eclipse (after mvn eclipse:eclipse) and firering a GET to \n\n```sh\nlocalhost:8080/files\n```\n(e.g. with [Postman]) should work (giving something like \"File reading successfull\"). Inside your IDE, the Path will look something like this:\n\n```sh\njar:file:/C:/dev/temp/springbootreadfilejar/target/springbootreadfilejar-0.0.1-SNAPSHOT.jar!/files/homepage-feature-projects.png\n```\n\n\nThen, run it with something like\n```sh\njava -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar springbootreadfilejar-0.0.1-SNAPSHOT.jar\n```\nand create a remote-debug-configuration in eclipse, when you´re inside the project.\n\nThen run your debugger. Firering to the url again - does it work?\n\nNow the Path is magically looking like\n\n```sh\njar:file:/C:/dev/temp/springbootreadfilejar/target/springbootreadfilejar-0.0.1-SNAPSHOT.jar!/files/homepage-feature-projects.png\n```\n\n### But that´s all to much effort!\n\nBecause you can just use org.springframework.core.io.Resource with @Value-Annotation - and all the Stuff is handled by Spring for you!\n\nLook at the second Method inside [FileReader-Class] and run the second test. Just\n\n```sh\n@Value(\"classpath:files/homepage-feature-projects.png\")\nprivate Resource file;\n\nfile.getInputStream();\n```\n\nThat´s it.\n\n[Issue]:http://stackoverflow.com/questions/25032716/getting-filesystemnotfoundexception-from-zipfilesystemprovider-when-creating-a-p\n[Oracle]:http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html\n[Postman]:https://www.getpostman.com/\n[FileReader-Class]:https://github.com/jonashackt/springbootreadfilejar/blob/master/src/main/java/de/jonashackt/file/FileReader.java\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fspringbootreadfilejar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonashackt%2Fspringbootreadfilejar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fspringbootreadfilejar/lists"}