美文网首页
使用Maven下载源码

使用Maven下载源码

作者: 阿太哥 | 来源:发表于2017-04-20 23:20 被阅读182次

    maven查看项目的结构

    mvn dependency:tree | findstr ??

    配置maven下载源码

    参考:http://blog.csdn.net/mlin_123/article/details/50754433

    -- rabbitmq

    http://www.cnblogs.com/leocook/p/mq_rabbitmq_5.html

    修改maven的配置文件settting.xml 添加profiles和activeProfiles

    <profiles>

     <profile>

       <id>downloadSource</id>

       <properties>

            <downloadSources>true</downloadSources>

           <downloadJavadocs>true</downloadJavadocs>

      </properties>

    </profile>

    </profiles>

    <activeProfiles>

    <activeProfile>downloadSource</activeProfile>

    </activeProfiles>

    注意profiles或activeProfiles节点可能已经声明了

    然后在idea中设置maven importing的时候需要下载源码或doc

    File>setting>Build,Execution,Deployment>Build Tools>Maven>Importing

    勾选Automatically download后的source或documention 意思是在maven项目importing的时候下载源码或doc文档(一般我就勾选Sources下载相关源码) 

    一切准备就绪,友情提示,手动reimport maven是不能下载的,需要在项目的本地目录下(和pom一个目录)执行mvn dependency:sources 或mvn dependency:resolve -Dclassifier=javadoc

    第一个命令是下载源码,第二个命令是下载文档。

    执行完后,如果不出意外,查看你的project structure>libraries 点击你的maven依赖的jar包就可以在右边看到Sources下有个本地的链接执行相关源码,你的maven仓库下也会下载对应的资源。

    setting中最好配置镜像仓库的地址,以提高下载速度或自己搭建Nexus私服

    ------profiles

    profiles从字面上的理解是个性化配置。主要包含actication,repositories,pluginRepositories,properties元素

    定义profile后需要激活才能使用。

    http://maven.apache.org/guides/introduction/introduction-to-profiles.html

    public static voidmain(String args[]){

    //chacneId,labelId

    Long chanceId=null;

    Long labelId=null;

    List list =newArrayList<>();//findListByChanceId

    if(list ==null|| list.size() ==0){//这里可以不要

    Label curL =null;//get label from db

    LabelChance labelChance =newLabelChance();

    labelChance.setChanceId(chanceId);

    labelChance.setLabelId(labelId);

    //set createDate,updateDate

    labelChance.setCoreTag(curL.getUpgradeConfig()==0?0l:1l);

    //service.save(labelChance);

    return;

    }

    //否则数据库里有记录了

    LabelChance curLC=null;

    LabelChance coreLC =null;

    for(LabelChance lc : list){

    if(lc.getLabelId() == labelId) {

    curLC = lc;

    }

    if(lc.getCoreTag() ==1) {

    coreLC = lc;

    }

    }

    List lcs =null;//该集合存放需要修改维护的对象

    //本次label不在数据库中,需要新增

    if(curLC ==null) {

    Label curL =null;//get from db

    LabelChance labelChance =newLabelChance();

    labelChance.setChanceId(chanceId);

    labelChance.setLabelId(labelId);

    labelChance.setCreateDate(newDate());

    labelChance.setLabel(curL);//...

    lcs =fileList(labelChance,coreLC);

    }else{//包含本次

    lcs =fileList(curLC,coreLC);

    }

    //service.updateBatch(lcs);

    }

    //当前labelId等于core.labelId?

    public staticListfileList(LabelChance curLC,LabelChance coreLC){

    Date now =newDate();

    curLC.setUpdateDate(now);

    List list =newArrayList<>();

    if(curLC.getLabel().getUpgradeConfig() ==0) {//不参与主标签竞选

    curLC.setCoreTag(0l);

    list.add(curLC);

    }else if(coreLC ==null){//要参与主标签,且coreLC为空

    curLC.setCoreTag(1l);

    list.add(curLC);

    }else if(curLC.getLabel().getWeight()>coreLC.getLabel().getWeight()

    || (newDate().getTime()-coreLC.getUpdateDate().getTime())/(1000*60*60*24) >= coreLC.getLabel().getValideDate()){

    //参与主标签分配 且coreLC不为空

    //1 curL.weight>=coreLC当前为主

    //2 curL.weight <= coreLC.weight看有效期 如果原主标签过期 当前为主

    curLC.setCoreTag(1l);

    list.add(curLC);

    if(curLC.getLabelId() != coreLC.getLabelId()) {

    coreLC.setCoreTag(0l);//取消旧的机会主标签。updateDate不变

    list.add(coreLC);

    }

    }else{

    //所有情况都不满足(curLC要参与主标且权重小了或 主标签没过期)

    curLC.setCoreTag(0l);

    list.add(curLC);

    }

    returnlist;

    }

    相关文章

      网友评论

          本文标题:使用Maven下载源码

          本文链接:https://www.haomeiwen.com/subject/alixzttx.html