zoukankan      html  css  js  c++  java
  • Maven入门----MyEclipse创建maven项目(二)

    新建项目:

    Next

    next

    next

    新建项目后,MyEclipse会自动从远程仓库中下载支持包,需要几分钟左右时间。

    项目结构图:

    HelloWorld.java

    public class HelloWorld {

        

        public String say(){

            return "Hello World";

        }

        

        public static void main(String []args){

            System.out.println(new HelloWorld().say());

        }

    HelloWorldTest.java

    import static org.junit.Assert.*;

    public class HelloWorldTest {

        

        public void testSay(){

            HelloWorld helloWorld = new HelloWorld();

            String result = helloWorld.say();

            assertEquals("Hello World",result);

        }

    Pom.xml在创建项目的时候会自动生成。不过生成的pom.xml里面的junit版本是3.1*的,不是太好用,自己动手改成4.12比较好,改成以后会自动从远程仓库中取回jar包的。

    一般不会有什么问题,如果有问题一般是jdk的版本问题,但是我这里也没出什么错误,看到别人网上说的3.1版本以上的Maven需要用1.7版本及以上的jdk,一定要是jdk,不能是jre.

    指定jdk

    测试:右键pom.xml,

    结果:

    其他的clean,install,可以自己尝试,都是一样的用。

  • 相关阅读:
    Find the Smallest K Elements in an Array
    Count of Smaller Number
    Number of Inversion Couple
    Delete False Elements
    Sort Array
    Tree Diameter
    Segment Tree Implementation
    Java Programming Mock Tests
    zz Morris Traversal方法遍历二叉树(非递归,不用栈,O(1)空间)
    Algorithm about SubArrays & SubStrings
  • 原文地址:https://www.cnblogs.com/bb1119/p/5564648.html
Copyright © 2011-2022 走看看