maven使用
2015-07-13 18:19
411 查看
一、maven配置仓库地址
在setting.xml里面配置<span style="font-family:SimSun;font-size:14px;"><profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.test.com/nexus/content/groups/public</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus-plug</id> <name>local private nexus-plug</name> <url>http://maven.test.com/nexus/content/groups/public</url> </pluginRepository> </pluginRepositories> </profile></span>
二、maven中央仓库包查询地址
http://search.maven.org/可以查询需要引入的包的版本仓库中有什么
三、maven版本会默认使用JDK比如1.5
法一:项目建立后修改JDK依赖版本。项目右键--Properties--Libraries选项卡选项修改成本地的JDK版本法二:修改Maven默认JDK版本,也在setting.xml里:http://blog.csdn.net/hehexiaoyou/article/details/27229881
四、maven编译
1)Eclipse配置maven编译 菜单栏Run--Run Configurations--Maven Build--右键New--Main选项卡见下图
2)常用命令说明:http://www.cnblogs.com/xing901022/p/4170248.html
五、maven进行单元测试
Maven可以使用Junit进行单元测试1)Junit4开始支持@Test
因此maven的pom.xml需要添加
<span style="font-family:SimSun;font-size:14px;"><dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency></span>运行结果
2)在src/test目录新建test类,一般test类的命名以被测试类后面加上Test命名
被测试类代码
<span style="font-family:SimSun;font-size:14px;">public class MavenEG {
public String sayHello() {
return "Hello Maven!";
}
}</span>测试类代码
<span style="font-family:SimSun;font-size:14px;">public class MavenTest {
@Test
public void testSayHello() {
MavenEG mavenEG=new MavenEG();
String result=mavenEG.sayHello();
assertEquals("Hello Maven!",result);
}
}</span>3)开始测试
法一:使用Junit测试,在方法上右键--Run As--Junit Test
在Junit窗口可以看见测试结果,绿色条是通过(Junit窗口 windows--ShowView--Java--junit)
法二:菜单栏Run--Run Configurations--Junit--右键New--Main选项卡
见下图:Test method默认是所有方法
运行结果
六、创建和导入maven项目
1)新建项目:http://www.cnblogs.com/leiOOlei/p/3361633.html2)导入项目: 菜单File--Import--Maven下面--Existing Maven Project
不断更新中……
相关文章推荐
- Java中三个引用类SoftReference 、 WeakReference 和 PhantomReference的区别
- 关于static text文字修改颜色和字体的解决办法
- 应用程序配置文件
- 已经包含了#include <atlcom.h> #include <comutil.h>还是报错
- Linux下自动获取和静态配置IP的方法
- InnoDB独立表空间
- 三步学会用spring开发OSGI——(第三步:WEB篇)
- IOS
- bug集
- 三步学会用spring开发OSGI——(第二步:工程篇)
- 三种DLL(Win32DLL,MFC常规DLL和MFC拓展DLL)的简单学习总结
- LOJ 1070 - Algebraic Problem(矩阵快速幂啊)
- 判断EditText是否有焦点,如果有,则清除焦点
- Lua5.1.4代码分析(二十三)-如何实现Lua代码的热更新
- Linux下ifconfig命令的扩展实用
- 百度系统出现漏洞,被链家网霸屏置顶,到底是人为还是内部合作?
- 黑马程序员——IOS基础之C语言---C语言基础知识介绍
- HDU — 4240 Route Redundancy(最大流)
- Linux core dump详解
- [ccf 4] 网络延时