• maven 之在Eclipse中使用maven


    1. 在eclipse中使用maven:

    • 将插件包解压到eclipse的home目录下
    • 在dropins目录中编辑一个maven.link文件
      path=D:\develop\eclipse\maven
    • 删除configuration目录下的:org.eclipse.update文件夹。
    • 启动eclipse检查window下preference中是否有maven选项。
    • 在maven下的installations中配置自己安装maven的路径。
    • 通过user settings可以设置maven的配置文件。

    2.在eclipse中使用maven进行开发项目:

    • 新建项目时,选择maven project
    • 下一步时,第一次创建maven项目默认即可。

        

    • 选择一个骨架,来创建maven项目

      

    • 下一步 填写项目的相关信息

    • finish后,maven项目创建完成。

    • 查看 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>cn.sxt</groupId>
      <artifactId>hello</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>
      <name>hello</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.10</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
    </project>
    • 在源码包下编写代码
    public class Calculator {
        public int add(int a,int b){
            return a+b;
        }
    }
    • 在测试包下编写测试代码:
      import org.junit.Test;
      import static junit.framework.Assert.*;
      public class CalculatorTest {
          @Test
          public void testAdd(){
              assertEquals(3, new Calculator().add(2, 1));
          }
      }
    • 在项目上右击,执行maven的相关命令:

    • 在myeclipse中,自动集成maven,建议大家使用自己的maven,设置方式和eclipse一致,不用添加插件步骤即可。

       

  • 相关阅读:
    TCP/IP和HTTP协议代理
    HTTP与HTTPS的区别
    HTTP头HOST
    租户、租户管理员、部门管理员和开发者在APIGW中的角色
    HTTP协议扫盲(八 )响应报文之 Transfer-Encoding=chunked方式
    Java的Socket通信
    开发一个http代理服务器
    需求迭代:迭代需求矩阵
    产品功能对标
    GIT入门笔记(20)- 使用eclipse 基于 git 开发过程梳理
  • 原文地址:https://www.cnblogs.com/forever2h/p/6857010.html
Copyright © 2020-2023  润新知