欢迎访问个站,一起努力呀
废话少说,直接开始, 配置这种东西力求简单,不过分描述:
一、安装 Maven (Win7 64bit 为例)
1). Apache 官网下载 Maven
2). 解压就OK了,配置本机环境变量:
A:新建:
变量名:MAVEN_HOME
变量值:D:\软件包汇总\MavenJavaProjectManage\apache-maven-3.6.0
B:编辑:
找到变量名:Path
需要编辑的值:;%MAVEN_HOME%\bin; (注意前后的分号)
3). 测试安装结果:
如下即安装成功:
二、配置中央仓库和本地Maven仓库
1). 中央仓库:
apache-maven-3.6.0\conf\settings.xml, 如下配置(这里选择使用阿里云的中央仓库):
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
2). 本地 Maven 仓库:
创建本地Maven 仓库,在 setting.xml 中配置
apache-maven-3.6.0\conf\settings.xml, 如下配置,如此自动下载导入的依赖都会存在这里:
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->
<localRepository>D:\软件包汇总\MavenJavaProjectManage\Maven_House</localRepository>
三、工程配置
1).这里就比较简单了,创建 Maven 项目:
2) 一路向下,注意这个地方:
填写 Maven 安装目录路径:
创建完成,工程自动生成 pom.xml, 项目依赖就在此xml文件中导入
阿里云:仓库服务
复制Maven依赖在pom.xml 中填写,如下:
右键项目属性, 找到Reimport 将依赖下载到本地Maven 仓库中
Over
四、导入测试
package packageone;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import java.util.List;
public class TestNing {
@Test
public void test1() {
// 连接Redis 服务
Jedis jedis = new Jedis("xxx.xxx.xxx.xxx", Integer.parseInt("6379"));
System.out.println("连接成功");
//查看服务是否运行
System.out.println("服务正在运行: "+jedis.ping());
jedis.select(4);
jedis.set("1", "Test1");
jedis.set("2", "Test2");
jedis.set("3", "Test3");
jedis.set("4", "Test4");
jedis.set("5", "Test5");
jedis.set("6", "Test6");
System.out.println("redis 存储的字符串为: "+ jedis.get("1"));
System.out.println("redis 存储的字符串为: "+ jedis.get("2"));
System.out.println("redis 存储的字符串为: "+ jedis.get("3"));
System.out.println("redis 存储的字符串为: "+ jedis.get("4"));
System.out.println("redis 存储的字符串为: "+ jedis.get("5"));
System.out.println("redis 存储的字符串为: "+ jedis.get("6"));
}
}
Redis 就导入了工程了.至于后续的打包发布等,用到了再试试.
赐教!