First step: First import the two maven project Hello and hellofriendcreated by the previous command line.
Method: Select the file-->import-->existing MAVEN PROJECTS option to select the corresponding project path to import
Step two: Construct the purpose of the Hello and hellofriend items sequentially
Method: Right-click on the respective project pom.xml file and select the maveninstall command in run as to install the widget into the warehouse
Step three: Create a third maven project through Eclipse . Select the file-->new-->other-->mavenproject option
Fourth step: Create a new file in 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.";
System.out.println (str);
Returnstr;
}
}
Fifth step: Create a new file in 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);
}
}
Sixth step: Click on the root directory pom.xml add dependencies
<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>
Seventh Step: Right-click pom.xml Select command execution in run as
Create a new MAVEN project in 7.Eclipse