运行时期望获得的jar包版本信息
pom.xml
<groupId>com.xxx.yyy</groupId>
<artifactId>xxxxxxx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>xxxxxx</name>
<description>yyyyyyy</description>
代码获取
场景描述:
下面的代码是独立的功能组件Jar包, 向外提供@EnableXXXX的注解. 在初始化时, 从使用@EnableXXXX的Springboot应用中获取其相关的版本信息.
Map<String, Object> mapper = SpringContext.getApplicationContext().getBeansWithAnnotation(xxxx.class);
Optional<Package> annotationPkg = Optional.ofNullable(mapper.values().toArray()[0].getClass().getPackage());
String implementationTitile = annotationPkg.get().getImplementationTitle();
String implementationVersion = annotationPkg.get().getImplementationVersion();
最后
以上就是娇气裙子最近收集整理的关于Springboot获得pom中版本信息pom.xml代码获取的全部内容,更多相关Springboot获得pom中版本信息pom内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复