码迷,mamicode.com
首页 > 编程语言 > 详细

006Maven_在Myeclipse创建java项目

时间:2016-08-26 19:47:38      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

第一步:

技术分享

第二步:

技术分享

 

第三步:

技术分享

第四步:

技术分享

 

 

经过以下的步骤:

项目如下:

技术分享

 

 

上面的a.b/Sdcard.java代码如下:

package a.b;

/**
 * Hello world!
 *
 */

    public class Sdcard{
          public String getVender(){
              return "sandisk";
          }
        }

a.b/SdcardTest.java代码如下:

package a.b;

import org.junit.Test;

/**
 * Unit test for simple App.
 */
public class SdcardTest 
   
{
   @Test
    public void testApp()
    {
        Sdcard sdcard = new Sdcard();
        String verder = sdcard.getVender();
        System.out.println("生产商:"+verder);    
    }
}

pom.xml代码如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>MyHello</groupId>
  <artifactId>MyHello</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>MyHello</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.9</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

 

 

测试:

MyHello->Run as->Maven test.

测试通过:

[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MyHello 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MyHello ---
[INFO] Using ‘UTF-8‘ encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\MyEclipseWorkspaces\MyHello\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ MyHello ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MyHello ---
[INFO] Using ‘UTF-8‘ encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\MyEclipseWorkspaces\MyHello\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ MyHello ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MyHello ---
[INFO] Surefire report directory: D:\MyEclipseWorkspaces\MyHello\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running a.b.SdcardTest
生产商:sandisk
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.044 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MyHello ---
[INFO] Building jar: D:\MyEclipseWorkspaces\MyHello\target\MyHello-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MyHello ---
[INFO] Installing D:\MyEclipseWorkspaces\MyHello\target\MyHello-0.0.1-SNAPSHOT.jar to E:\mvn_repo\repository\MyHello\MyHello\0.0.1-SNAPSHOT\MyHello-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\MyEclipseWorkspaces\MyHello\pom.xml to E:\mvn_repo\repository\MyHello\MyHello\0.0.1-SNAPSHOT\MyHello-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.527 s
[INFO] Finished at: 2016-08-26T18:20:54+08:00
[INFO] Final Memory: 6M/75M
[INFO] ------------------------------------------------------------------------

 

006Maven_在Myeclipse创建java项目

标签:

原文地址:http://www.cnblogs.com/shenxiaoquan/p/5811455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!