maven之nexus

新建source folder src/main/resources
                  src/test/resources

maven隐藏变量【先run clean install】
 ${basedir} 项目根目录
${project.build.directory} 构建目录,缺省为target
${project.build.outputDirectory} 构建过程输出目录,缺省为target/classes
${project.build.finalName} 产出物名称,缺省为${project.artifactId}-${project.version}
${project.packaging} 打包类型,缺省为jar
${project.xxx} 当前pom文件的任意节点的内容

 <dependency>
    <groupId>${project.groupId} </groupId>
     <artifactId>user-log</artifactId>
      <version>{project.version}</version>必须版本一致

                  出现Missing artifact:删除包下面的东西,重新maven install

maven依赖特性:
test范围指的是测试范围有效,在编译和打包时都不会使用这个依赖
compile范围指的是编译有效,编译和打包都不会将依赖存储进去
provide依赖在编译和测试有效,最后生成war包时不会加入
4runtime在运行时依赖有效,在编译时候不依赖
默认compile
当依赖级别相同时,哪个依赖就用哪个依赖,当依赖级别不同时哪个层级少,就用哪一个
maven的继承和聚合
根目录建pom
new ->other->mavenproject->create simple project+use deault work space ->quick start->groupid:zttc.itat.user artfiact:user-aggregation package:pom
导入两个模块,并且聚合在一起
<modules>
<module>../user-log</module>
<module>../user-service</module>
</modules>
对pom run as clean
结果user-log 和user-service 下的target就不存在了(刷新)
clean package
定义常量
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  new ->other->mavenproject->create simple project+use deault work space ->quick start->groupid:zttc.itat.user artfiact:user-parent package:pom
  添加以下到parent中
      <name>user-aggregation</name>
        <url>http://maven.apache.org</url>
   <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
  在子类中
  <parent>
<groupId>zttc.itat.user</groupId>
<artifactId>user-parant</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../user-parant/pom.xml</relativePath>

</parent>
依赖管理
<dependencyManagement>
  <dependencies>
  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
      
    </dependency>
    <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.9</version>
</dependency>

  </dependencies>

  </dependencyManagement>
 
maven私服
http://www.sonatype.org/nexus/go/


1.下载     Nexus 2.3.1
2.配置环境变量
3.cmd下运行nexus
Usage: nexus { console : start : stop : restart : install : uninstall }
修改java的绝对路径
E:\Program\nexus-2.3.1\bin\jsw\conf
wrapper.java.command=E:\Program\Java\bin\java
C:\Users\Administrator>nexus install
wrapper  | nexus installed.
C:\Users\Administrator>nexus start
wrapper  | Starting the nexus service...
wrapper  | Waiting to start...
wrapper  | Waiting to start...
wrapper  | Waiting to start...
wrapper  | nexus started.
管理页面http://localhost:8081/nexus/index.html#welcome log in用户名admin密码admin123
host type
mvn:deploy  -->release/snapshots
3rd part自己上传或者通过pom管理
设置私有工厂使他不从中央工厂下载
  <repositories>
  <repository>
  <id>nexus</id>
  <name>nexus repos</name>
  <url>http://localhost:8081/nexus/content/groups/public/</url>
 
  </repository>
 
 
  </repositories>
 若想多加几个工厂要么多写几个 <repository>,要么在nuxus界面通过group来配置,并且重写这个group的url
 
 若希望所有项目都在里面找那就设置setting
 设置多个工厂
  <profile>
      <id>nexusProfile</id>

      <repositories>
       
         <repository>
  <id>nexus</id>
  <name>nexus repos</name>
  <url>http://localhost:8081/nexus/content/groups/public/</url>
  <releases><enabled>true</enabled></releases><!--  默认开启可以下载release的jar包 -->
  <snapshots><enabled>false</enabled></snapshots><!--  默认关闭可以下载snapshots的jar包 -->
 
  </repository>
 
       
      </repositories>
    </profile>
 
激活(只有激活之后才生效)
  <activeProfiles>
    <activeProfile>nexusProfile</activeProfile>
  </activeProfiles>
 可以删除eclipse里面得repository
 若关闭后他会去maven的module build 里面去找
 配置工厂镜像,只要mirrorof中的工厂要访问,都会自动来找镜像,如果镜像无法访问,就无法访问了,使用*表示所有的都会使用来范文
      <mirror>
      <id>nexusMirror</id>
      <mirrorOf>nexus,central</mirrorOf><!--工厂id-->
      <name>Human Readable Name for this Mirror.</name>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
    </mirror>
 上面配置后nexusProfile就失效了
 重载中央工厂的配置使之支持snapshot
         <profile>
      <id>centralProfile</id>
     
<repositories>  
  <repository>  
    <id>central</id>  
    <name>Maven Repository Switchboard</name>  
    <layout>default</layout>  
    <url>http://*</url>  
    <snapshots>  
      <enabled>true</enabled>  
    </snapshots>  
  </repository>  
</repositories>
    </profile>
 
 
 激活中央工厂
 
 <activeProfile>centralProfile</activeProfile>

转载于:https://my.oschina.net/goudingcheng/blog/611951

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值