1. If you want maven projects to depend on another maven project, the dependent project must have corresponding jar packages in the maven repository. Therefore, you must execute the mvninstall command on the dependent project. 2. Create the HelloFriend directory of the second project module and the agreed directory structure vcmRlcj01cellspacing0cellpadding0HelloFriend -- src ----
1. If you want maven projects to depend on another maven project, the dependent project must have corresponding jar packages in the maven repository. Therefore, you must execute the mvninstall command on the dependent project. 2. Create the HelloFriend directory of the second project module and the agreed directory structure vcmRlcj0 = "1" cellspacing = "0" cellpadding = "0"> HelloFriend -- src ----
Zookeeper
1. If you want maven projects to depend on another maven project, the dependent project must have corresponding jar packages in the maven repository. Therefore, you must execute the mvninstall command on the dependent project.
2. Create the HelloFriend directory of the second project module and the agreed directory structure
VcmRlcj0 = "1" cellspacing = "0" cellpadding = "0">
|
HelloFriend
-- Src
----- Main
---------- Java
---------- Resources
----- Test
--------- Java
--------- Resources
-- Pom. xml |
3. Create pom. xml in the HelloFriend root directory of the project.
|
4.0.0
Cn. toto. maven
HelloFriend
0.0.1-SNAPSHOT
HelloFriend
Junit
Junit
4.9
Test
Cn. toto. maven
Hello
0.0.1-SNAPSHOT
Compile
|
4. Create the HelloFriend. java file in the src/main/java/cn/toto/maven directory.
|
Package cn. toto. maven;
Import cn. toto. maven. Hello;
Public class HelloFriend {
Public String sayHelloToFriend (String name ){
Hello hello = new Hello ();
String str = hello. sayHello (name) + "I am" + this. getMyName ();
System. out. println (str );
Return str;
}
Public String getMyName (){
Return "John ";
}
} |
5. Create the test file HelloFriendTest. java in the/src/test/java/cn/toto/maven directory.
|
Package cn. toto. maven;
Import static junit. framework. Assert. assertEquals;
Import org. junit. Test;
Import cn. toto. maven. Hello;
Public class HelloFriendTest {
@ Test
Public void tesHelloFriend (){
HelloFriend helloFriend = new HelloFriend ();
String results = helloFriend. sayHelloToFriend ("tuzuoquan ");
AssertEquals ("Hello tuzuoquan! I am John ", results );
}
} |
6. Run the mvn command in the HelloFriend directory (note the HelloFriend folder)
7. Run the mvnpackage command again in the HelloFriend directory.