发布于 2015-06-06 21:09:46 | 699 次阅读 | 评论: 0 | 来源: PHPERZ

这里有新鲜出炉的Maven教程,程序狗速度看过来!

Apache Maven 项目构建工具

Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统(Dependency Management System),和用来运行定义在生命周期阶段(phase)中插件(plugin)目标(goal)的逻辑。当你使用Maven的时候,你用一个明确定义的项目对象模型来描述你的项目,然后Maven可以应用横切的逻辑,这些逻辑来自一组共享的(或者自定义的)插件。


一、安装Nexus(Linux下)

    Nexus是典型的Java Web应用,它有两种安装包,一种是包含Jetty容器的Bundle包,另一种是不包含Web容器的war包。      

    1. 下载 

        官网下载很麻烦,这里有下好的Bundle包

    2. 安装

         # tar xzvf nexus-oss-webapp-1.8.0-bundle.tar.gz

    3. 启动

        进入cd  /usr/nexus/nexus-2.11.2-06/bin

        ./nexus start

      (输入./nexus 回车可以查看其他命令Usage: ./nexus { console | start | stop | restart | status | dump } ) 

       nexus默认监听的端口是8081。那么我们就可以在浏览器中访问:http://host:8081/nexus   

二、配置Nexus

默认的用户名和密码:admin/admin123(一般登陆以后要修改密码),端口如果有冲突可以在/usr/nexus/nexus-2.11.2-06/conf的nexus.properties里面修改,下面是一些必要的配置(把索引打开)

 

二、本地使用

    Maven安装可以参考 eclipse Maven安装配置 

    电脑安装好maven后,在${MAVEN_HOME}→conf→settings.xml配置、和修改存放jar包的路径(要在{MAVEN_HOME}新建repository文件夹,并将配置文件settings拷贝到repository文件下,方便Maven升级)

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
   
  <localRepository>${MAVEN_HOME}/repository</localRepository>

  <profiles>
  
    <profile>
       <id>dev</id>
          <repositories>
             <repository>
                 <id>nexus</id>
                 <url>http://xx.xx.xx.xx:8181/nexus/content/groups/public/</url>
                 <releases>
                    <enabled>true</enabled>
                 </releases>
                 <snapshots>
                    <enabled>true</enabled>
                 </snapshots>
              </repository>
            </repositories>           
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <url>http://xx.xx.xx.xx:8181/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
  </profiles>
  
  <activeProfiles>
        <activeProfile>dev</activeProfile>
    </activeProfiles> 
</settings>
记得Eclipse要修改指定的maven安装目录和指定的settings.xml位置

 
 

四、上传仓库没有的Jar包到nexus

 
使用 (拷贝到项目pom.xml使用)
 
效果
 
 
PS:别的同事初次部署可以将repository文件夹考到他电脑对应目录下,并在Eclipse指定版本和setting即可。


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务