获取JVM中的Spring和其他框架版本号
我正在尝试为基本的 java 应用程序创建一个“骨架”框架。
我想要添加的一件事是版本页面/显示,其中列出了当前附加的框架/库。
例如:
骨架版本:1.0.0 春季:2.5.6 Hibernate:Malbolge
Skeleton 项目的目的是让新开发人员能够轻松快速地启动一个强大的应用程序。
我认为最坏的情况是我可以搜索每个框架 jar 清单并使用它...但这并不有趣...
有人有不同的建议吗?如果项目要使用 Maven,这将是理所当然的...我可以解析 pom.xml 或某种程度的东西...
我想一个更明确的问题是:
给定一个 libs 文件夹;有没有一种方法可以在不接触清单的情况下动态收集 jars/frameworks 版本#?
I'm trying to create a 'skeleton' framework of sorts for a basic java app.
One thing I'm looking to add is a version page/display that list the current framework/libs attached.
For example:
Skeleton version: 1.0.0
Spring: 2.5.6
Hibernate: Malbolge
The purpose of the Skeleton project was to make it very easy for a new developer to quickly start a robust app.
I figured the worst case scenario is that I could search through every framework jars manifest and use that... but that's no fun...
Anyone have a different suggestion? This would be a no brainer if the project was going to use Maven... I could just parse the pom.xml or something to that extent...
I guess a more defined question is:
Given a folder of libs; is there a way to dynamically gather the jars/frameworks version # without touching the manifest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 获取 Spring 版本SpringVersion类。
我在上一个问题中有一个代码片段:
需要 Spring 版本# - 仅有 spring.jar 文件
You can get the Spring version using the SpringVersion class.
I had a code snippet in a previous question:
Need Spring version# - only have spring.jar file
使用 System.getProperties()< /a> 为您提供 JVM 属性列表,包括 JRE、JVM 和规范的不同版本 ID。不确定这是否会提供 Spring 等版本。
Using System.getProperties() gives you a listing of JVM properties including the different version ids of the JRE, JVM and specification. Not sure if this will give Spring etc versions.