How can I use Maven to automatically download any needed dependencies of my program?
I am new to using Maven.
I have Java files that have dependencies. Like for example:
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
In the development server, there is no Java compiler. I am planning to compile the Java files on the desktop and pack the classes into jar files and then execute the program on the development server.
The development server has all the required files, the desktop not yet. How can we use Maven to care of the issue while compiling it on the desktop?
EDIT:
I want to add data into hbase tables using Java. Hbase works fine in the dev server. I am abl开发者_Go百科e to create tables there through command line in dev serv. But hbase/hadoop is not there in the desktop environment.
So will downloading jars help, or do I need to setup hadoop and install hbase locally?
If I understand correctly, you need to configure some compile-time-only dependencies in your Maven pom. You can do it in the dependencies
section, e.g.:
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.2</version>
<scope>provided</scope>
</dependency>
...
</dependencies>
You need to determine the artifactId and version for each of the needed Hadoop packages, then add them to the dependencies.
Yes, Maven has a near vertical learning curve.
It looks like you are doing a very small inhouse job on your own, or with a very small team. In that case, it's probably enough if you set up an IDE (eclipse or NetBeans), resolving the dependencies manually (downloading jars in a /lib folder in the project), and compile and export a binary (jar) manually.
hadoop-core, hbase, and zookeeper are the required HBase dependencies. Additionally, you should try and use the Cloudera ones as they fix some additional bugs the Apache jars have. Look here.
Additionally, you do not have to install HBase locally. When you create the HBase configuration just change the zookeeper quorom to point to the server in which the Zookeeper resides.
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", SERVER);
conf.set("hbase.zookeeper.property.clientPort", PORT);
From the maven site, set the scope
to provided
for the dependency.
精彩评论