I need to get the value of the current version of the application in various parts of the code. A priori I thought about creating a class containing the version:
public class Version {
public static String getVersion(){
return "0.1.0";
}
}
But there must be a better way to do this (I believe).
I've seen that Java has a versioning specification , but I do not understand if it's for the same purpose I'm looking for.
Well, as I'm using Maven and there is the <version>
property in the configuration file, I thought it would be easier to update this property at the time of maintenance, just use this property throughout the project.
The question is: Is it possible to get this property? If so, how to do it?
If not, could you give me alternatives?