Reputation: 4609
I am new to using Maven to build projects. I understand that you declare dependencies inside the POM file that outline the jars that are needed for the project so that they get added to the build at compile time.
My question is, how does that work during development, when I need the jar file in order to develop the application? I thought that the point of Maven was that you don't have to actually have the jar file, it gets acquired and put into the war at build time. But if I'm developing and I need a jar file (say Jersey for example), I would still need to go out and grab the jar myself and put it in the lib directory in order to do the development work, right, so that I know what classes/methods are available to me in that .jar? Can someone explain to me what I am missing?
Will my import statements that reference the jersey classes will be resolved at compile time, since right now they are underlined in red since the jar is not currently present?
Upvotes: 1
Views: 356
Reputation: 7940
Once you have specified a dependency in Maven pom, then its maven's responsibility to download it. Remember Maven is not bothered whether you code has a dependency on that jar. So in your ide create Maven project [not simple java project], add all your dependencies in your pom, when you save the pom, all dependencies will be downloaded. If dependencies are not getting downloaded then you need to check you maven settings.xml file where repository url or credentials might not be correct.
Also want to ad build part details. Maven has lots of plugin available which can help you to package all your dependencies in war file[assembly plugin] or rpm [maven rpm plugin]. These plugins will wrap all your dependencies along with main jar to a single deployable file.
Upvotes: 1
Reputation: 11486
Firstly, with any Java Maven project, you will have to choose the option 'Build With Dependencies', especially if you are using NetBeans. With Eclipse, you can choose, 'Download Sources'. When that is done, the Maven dependencies (the JAR files) with then be downloaded.
In addition, you said that your import statements will be resolved at compile time. This is done when you click the 'Build With Dependencies' option (right-click the Java Project in NetBeans) as this will then download all the dependencies and build the application and resolve any imports that use the JAR libraries found in the pom.xml.
Upvotes: 1
Reputation: 4030
Your assumption or presumption or conception is wrong.
Let us take an example. You are creating a new web application project
Upvotes: 1