標籤:style io ar java sp 檔案 div on art
第一步:首先匯入前面命令列建立的兩個maven項目Hello和HelloFriend。
方法:選擇file-->import-->Existing MAVEN PROJECTS選項選擇對應項目路徑匯入即可
第二步:按順序先後執行Hello和HelloFriend項目的的構建
方法:右擊各自項目pom.xml檔案,選擇run as中的maveninstall命令將構件安裝至倉庫中
第三步:通過eclipse建立第三個maven項目。選擇file-->new-->other-->MAVENPROJECT選項
第四步:在src/main/java中建立檔案cn.toto.maven.MakeFriends.java
package cn.toto.maven;
public class MakeFriends {
public StringmakeFriends(String name){
HelloFriendfriend = new HelloFriend();
friend.sayHelloToFriend("litingwei");
String str= "Hey,"+friend.getMyName()+" make a friend please.";
System.out.println(str);
returnstr;
}
}
第五步:在src/test/java中建立檔案cn.toto.maven.MakeFriendsTest.java
package cn.toto.maven;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.*;
import org.junit.Test;
public class MakeFriendsTest {
@Test
public voidtestMakeFriends(){
MakeFriendsmakeFriend = new MakeFriends();
String str= makeFriend.makeFriends("tuzuoquan");
assertEquals("Hey,Johnmake a friend please.",str);
}
}
第六步:點擊根目錄pom.xml添加依賴
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.toto.maven</groupId>
<artifactId>HelloFriend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
第七步:右擊pom.xml選擇run as中的命令執行即可
7.Eclipse中建立新Maven項目