I’m new to maven and am converting a java web app to maven (instead of managed by my IDE). I understand that can install the dependency locally (first choice) or declare it as a provided dependency (second choice). I read about what groupId, artifactId, and version mean. However, it doesn’t explain how to determine the exact coordinates of a jar.
The jar in question (servlet-api.jar of apache-tomcat 7.0.34) for example, doesn’t have a pom.xml file in the jar.
When you have a random jar file, in this case servlet-api.jar, present in some folder, you have to poke around to figure out if it is the same as some version.
One:Look inside the jar and note the date (or date range) of the files inside it. You might notice what files are in there. You might need that detail.
Two: Go to somewhere that you can look for the jar. I like http://mvnrepository.com/ where you can type in the name of the jar. "servlet-api". I found this one in about 10 seconds:
But its not yours. (Another 30 seconds and I found this: mvnrepository servlet-api for tomcat 7.0.34)
Reading the other answers reminded me that with the Java EE jars, I find it best to use a generic version for building your application. Use "provided" for the maven scope. The the container will provide the real jar and, if it isn’t totally standard, you won’t be using the non-standard parts because your build used the generic version.
So, for example, you might build with: