3. Add the maven project jar to the maven repository. The Mave project depends on another Maven project.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.