由于目前java memcached client没有官方的maven repository可供使用,因此使用时需要手动将其安装到本地repository。java memcached client的jar包下载地址:https://github.com/gwhalin/Memcached-Java-Client /downloads 目前2.6.2版本的java memcached client要依赖slf4j-simple、slf4j-api、commons-pool三个包,依此我们可以为其编辑一个pom文件,将java memcached client的jar包和pom文件一起安装,解决java memcached client对其他jar包的依赖。安装命令:
mvn install:install-file -Dfile=/path/to/java-memcached-release_2.6.2.jar -DpomFile=/path/to/java-memcached-2.6.2.pom
其中java-memcached-2.6.2.pom的内容为:
注意不要有空格或换行,否则执行命令会报解析pom文件错误
<?xml version="1.0" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>com.danga</groupId> <artifactId>java-memcached</artifactId> <version>2.6.6</version> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> <version>1.5.6</version> </dependency> </dependencies> </project>