Maven项目工程环境配置

maven

(断言) #1

1.apache-maven-2.2.1.rar拷贝解压

环境变量设置


mvn -version 验证安装结果
image

2.拷贝settings.xml文件到C:\Users\liuting.lt.m2下面,打开eclipse在windows->preference中maven->user settings中选择

C:\Users\liuting.lt.m2\setting.xml

3.到java的工作目录下D:\liuting\workspace

通过CMD

用maven2创建第一个java工程

mvn archetype:create -DgroupId=com.efn -DartifactId=study

进入D:\liuting\workspace\study

通过CMD在D:\liuting\workspace\study

mvn eclipse:eclipse

4.在eclipse中import这个study工程

添加需要的dependence到pom.xml中

<dependency>

<groupId>com.alibaba.crm.shared</groupId>

<artifactId>jtester</artifactId>

<version>1.1.8</version>

<scope>test</scope>

</dependency>

</dependencies>

jtester-1.1.8.jar被添加进来

5.建一个新类

package com.efn;

import org.jtester.testng.JTester;

import org.testng.annotations.Test;

public class SimpleTest extends JTester {

@Test

public void testDemo()

Unknown macro: { System.out.println("简单测试,演示!"); }

}

run as testNG

JMockit报错

实际调用:

public void initializeAccordingToJDKVersion()

{

String jarFilePath = discoverPathToJarFile();

if (Startup.jdk6OrLater)

Unknown macro: { new JDK6AgentLoader(jarFilePath).loadAgent(); }

else if ("1.5".equals(Startup.javaSpecVersion))

Unknown macro: { throw new IllegalStateException( "JMockit has not been initialized. Check that your Java 5 VM has been started " + "with the -javaagent}

else

Unknown macro: { throw new IllegalStateException("JMockit requires a Java 5 VM or later."); }

}

当不是jdk1.5版本的时候,报下面的错JMockit requires a Java 5 VM or later.

否则报错JMockit has not been initialized. Check that your Java 5 VM has been started

解决方法:

在eclipse中添加windows->preference->java->install JREs edit

在default vm argument中添加文件:

D:\m2\com\alibaba\external\test.jmockit\0.999.10\test.jmockit-0.999.10.jar



(冰河) #2

好的开始:man_dancing:t2: