admin管理员组文章数量:1122832
I have a working spring boot app executing from a jar that exposes a REST API, which is documented with springdoc/openapi/swagger by exposing on my spring boot app, too.
I can create the javadoc jar with maven, and I'd like to expose those javadocs with my spring boot app. I am able to do so if I manually unzip the jar into a directory like /static which spring boot puts into its executable jar. No problems.
But I'd like to skip the manual unzip and just use the javadoc.jar itself. However, if I do that, an http browser request will just download the jarfile, which is undesirable.
I know that Java is designed to easily read a jar file without unzipping it by setting the classpath to the jar file. It seems that spring might have a bean for effectively reading websites inside a jar, like what javadoc makes.
What I would like is for the user to enter http://localhost:8080/myapp/javadoc/index.html and spring boot would get the index.html out of /static/javadoc.jar, directly without unzipping... is that possible?
I have a working spring boot app executing from a jar that exposes a REST API, which is documented with springdoc/openapi/swagger by exposing on my spring boot app, too.
I can create the javadoc jar with maven, and I'd like to expose those javadocs with my spring boot app. I am able to do so if I manually unzip the jar into a directory like /static which spring boot puts into its executable jar. No problems.
But I'd like to skip the manual unzip and just use the javadoc.jar itself. However, if I do that, an http browser request will just download the jarfile, which is undesirable.
I know that Java is designed to easily read a jar file without unzipping it by setting the classpath to the jar file. It seems that spring might have a bean for effectively reading websites inside a jar, like what javadoc makes.
What I would like is for the user to enter http://localhost:8080/myapp/javadoc/index.html and spring boot would get the index.html out of /static/javadoc.jar, directly without unzipping... is that possible?
Share Improve this question asked Nov 22, 2024 at 21:04 jtalicsjtalics 1032 silver badges6 bronze badges 1- 1 Most performant way would be to include static generation of java doc during build time as maven build step and package/dockerize it, and then expose an api to read the statically generated content. Every version will generate and overwrite the static file. – zookastos Commented Nov 24, 2024 at 4:47
1 Answer
Reset to default 1You can distribute Javadocs file directly from a .jar in your Spring Boot app by developing a custom controller that can use the JarFile API to read and run files dynamically without unzipping. This helps you to access Javadoc files through URLs like /myapp/javadoc/index.html, making sure a clean and structured solution customized to your needs.. Optional Optimizations Cache Javadoc Files: If you expect high traffic, you can extract the Javadoc files into a temporary directory on startup and serve them from there for better performance. Add Security Filters: Validate the filePath parameter to avoid directory traversal attacks or unauthorized access to other files in the
本文标签: javaPossible for Spring Boot to serve javadocs without unzipping javadocjar manuallyStack Overflow
版权声明:本文标题:java - Possible for Spring Boot to serve javadocs without unzipping javadoc.jar manually? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300864a1930973.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论