How to add dependencies for maxmind geoip2 eclipse

2019-08-09 07:37发布

问题:

I'm trying to use MaxMind's GeoIP2 database, I've added the jar to my Java build path and configured it with Javadoc and source but when I run the program I get a NoClassDefFound error, which according to this stack overflow answer is because I need to add the dependencies, but I have no clue how to add them in eclipse, I tried extracting the jar files and adding them to the build path but that didn't work, how do I do this in eclipse?

Thanks for any help.

回答1:

In eclipse you have to create a new maven java project. If you dont know maven you can get informations here:

apache maven startsite

how to install maven

Afer that you are able to configure your dependencies in your pom.xml file. Which is the configuration file for maven.

You can find some dependencies for your usage here:

maxmind documentation

The include of the dependency would look like this:

 <dependency>
    <groupId>com.maxmind.geoip2</groupId>
    <artifactId>geoip2</artifactId>
    <version>v2.3.0</version>
</dependency>

But first, you should look at maven installation and using. It will make your life easier by handling all the necessary dependencies you will need in this project and in all of your other projects in future.