是否可以使用 Maven Javadoc 插件扩展 javadoc 上的 Maven 属性范围?例如。
/**
* My Awesome Class
* @version ${project.version}
**/
我想你可以这样尝试。这是两步过程:
首先是将pom属性加载到静态字段中
其次使用静态字段设置javadoc属性
创建一个app.properties
in src/main/resources
像这样的内容
application.version=${project.version}
然后像这样启用maven过滤
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
在应用程序代码中只需读取属性文件
public class MVNLinksHolder{
public static String version = "";
public MVNLinksHolder(){
ClassPathResource resource = new ClassPathResource( "app.properties" );
Properties p = new Properties();
InputStream inputStream = null;
try {
inputStream = resource.getInputStream();
p.load( inputStream );
version = p.getProperty("application.version");
}
catch ( IOException e ) {
LOGGER.error( e.getMessage(), e );
}
finally {
Closeables.closeQuietly( inputStream );
}
}
}
然后用它来设置版本
/**
* My Awesome Class
* @version = {@value MVNLinksHolder#version}
**/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)