Maven Note

maven:

  pom: project object model
  plugin:  maven具体的功能都是靠插件完成,maven本身很小,很多功能来源于插件。


maven版本和jdk相关版本:

  maven 3.3 require是JDK1.7 or above,Maven 3.2 requires JDK1.6 or above ,while Maven 3.0/3.1 requires JDK1.5 or above.


maven环境配置:

  1.需要jdk环境,
  2.需要在path路径下配置bin目录


maven资源库配置:

  1. conf目录下的setting.xml文件里面需要配置资源曾库的路径	
            <localRepository>D:\apache-maven-3.3.9\Repository</localRepository>	
  2.如果公司内网需要特别的代理,则我们还需要配置代理
            <proxies>
          	<proxy>
          		<id>ncs</id>
          		<protocol>http</protocol>
          		<active>true</active>
          		<host>proxy.ncs.com.sg</host>
          		<port>8080</port>
          		<username>ncs\p1311788</username>
          		<password>R@yner`12</password>
          		<nonProxyHosts>10.70.*|192.168.*|localhost|ilabs.ncs.com.sg|projectconnect.ncs.com.sg</nonProxyHosts>
          	</proxy>
          </proxies>	  
  3.也可以在配置文件内部配置全局JDK
          <!--全局JDK配置,1.8版本-->
          <profile>    
              <id>jdk-1.8</id>    
              <activation>    
                  <activeByDefault>true</activeByDefault>    
                  <jdk>1.8</jdk>    
              </activation>    
              <properties>    
                  <maven.compiler.source>1.8</maven.compiler.source>    
                  <maven.compiler.target>1.8</maven.compiler.target>    
                  <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>    
              </properties>    	  
          </profile>


maven常用命令

   1.编译 mvn compiler
   2.测试 mvn mvn test  可以以mvn test -Dtest=${类名} //单独运行测试类
          //运行测试(自动运行测试代码),会先对代码自动编译,生成target包和测试报告
   3.清除 mvn clean //清除原来编译的结果
          //会将编译出来的target包删除
   4.打包 mvn package, mvn package -Dmaven.test.skip //打包时不执行测试代码
          //java项目自动打包为jar包, web项目自动打包为war包
		  //打出来的包的名称  工程名称(即 artifactID)-版本版本性质.jar(或.war)
		 
   5.安装发布 mvn install //将项目打包成构件安装到本地仓库
             mvn deploy  //发布项目到本地曾库或服务器(例如 tomcat,Jboss)
   

   6.将maven项目 转换为eclipse工程(即可以被eclipse识别)或IDEA项目	 
             转eclipse工程: mvn eclipse:eclipse
			               mvn eclipse:clean //清除eclipse设置信息
             转IDEA工程: mvn idea:idea
                        mvn idea:clean //清除idea设置信息


Maven仓库

    1.网络仓库:
          1.中央仓库: 官方服务器仓库
          2.公司仓库: 公司内部搭建服务器-私服 (可以存放一些公司私有的项目)
    2.本地仓库:
          1.就是自己在安装maven时,配置的那个本地repository(用户缓存从网络仓库下载下来的资源)		


pom.xml配置解读

    1.packaging 
          jar:表明这是一个java项目
          war:表明这是一个web项目
          pom:表示这是一个依赖的父项目,提供被子项目依赖	


    2.dependency内置参数配置详解
	      groupId:   组织ID
		  artifactId 项目名
		  version    版本号
		  type       项目类型,一般默认为jar,若项目依赖为war,则开发人员可以定义此为war
		  scope      依赖范围
              1.compile: 编译需要,打包需要(大多数jar都是这种) 默认值
              2.provide: 编译需要,不会被打包(servlet,jsp)
			  3.runtime: 编译不需要,打包运行时需要(jdbc驱动)
			  4.test:    参与测试,不会打包(junit)


Maven插件

    maven大部分功能都是靠插件完成的
    1.maven编译插件
	      <plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.1</version>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
				<encoding>utf-8</encoding>
			</configuration>
		   </plugin>
     
     2.。。。。。。		


资源依赖:

    <!--maven项目中,资源的依赖-->
	<resources>
		<resource>
			<directory>src/main/java</directory>
			<includes>
				<include>**/*.xml</include>
				<include>**/*.properties</include>
			</includes>
			<filtering>true</filtering>
		</resource>
		<resource>
			<directory>src/main/resources</directory>
			<includes>
				<include>**/*.properties</include>
				<include>**/*.xml</include>
				<include>**/*.tld</include>
			</includes>
			<filtering>true</filtering>
		</resource>
	</resources>		 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
m2maven插件 Installing m2eclipse Core To install m2eclipse, use the following Eclipse update site to install the core of the m2eclipse plugin. This Core update site contains a single component: "Maven Integration for Eclipse (Required)". When you install this component you will be installing all of the core Wizards, the POM Editor, Maven Repository integration, and Maven integration m2eclipse Core Update Site: http://m2eclipse.sonatype.org/sites/m2e IMPORTANT NOTE: You cannot upgrade from m2eclipse 0.9.8 or m2eclipse 0.9.9 to m2eclipse 0.10.0. If you are running m2eclipse 0.9.8 or 0.9.9 you must either uninstall m2eclipse from your Eclipse installation or start with a fresh installation of Eclipse. To install this plugin in the Eclipse IDE: Select Help > Install New Software. This should display the "Install" dialog. Paste the Update Site URL into the field named "Work with:" and press Enter. Pressing Enter should cause Eclipse to update list of available plugins and components. Choose the component listed under m2eclipse: "Maven Integration for Eclipse (Required)". Click Next. Eclipse will then check to see if there are any issues which would prevent a successful installation. Click Next and agree to the terms of the Eclipse Public License v1.0. Click Finish to begin the installation process. Eclipse will then download and install the necessary components. Once the installation process is finished, Eclipse will ask you if you want to restart the IDE. Sonatype strongly recommends that you restart your IDE after installing m2eclipse. Note about 0.9.8 Workspace Incompatibility: If you are using m2eclipse 0.10.0 with a workspace that contains projects created under m2eclipse 0.9.8, you must remove the workspaceState.ser file. The workspaceState.ser file is located within the workspace directory in $workspacedir/.metadata/.plugins/org.maven.ide.eclipse/workspaceState.ser. If you remove this file, m2eclipse 0.10.0 will regenerate it as needed.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值