最近使用的项目的开发maven,多于maven有项目之间有一定的联系,因此,创建一个单独的,然后,maven聚合管理。

项目采用git要管理代码。由于上传的代码集时,.gitignore不要上传文件.setting其他文件,因此,git下载之后maven一个elipse项目文件。这样假设在github中拉下代码之后,再导入时不是非常方便。所以这里使用maven的插件,把各个项目变成Eclipse项目。

项目的结构例如以下:

当中encryption是多个maven项目中的当中一个,这些项目都依赖Utils4Java-parent中的pom文件

Utils4Java-parent:

encryption项目(新建的其它maven项目结构也如此):

在这里除了pom文件之外其它项目没有打勾,是由于用git上传到github时在.gitignore文件中被忽略掉了,而src没有被上传是由于目录中我没有加源代码,是空的。

在这里能够看到eclipse项目文件标志的.setting没有被上传。

在eclipse中导入是这种:

一.怎样用maven管理多个项目

Utils4Java-parent的pom文件例如以下。全部的maven项目的pom文件都依赖这个父文件:

<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>com.kxw</groupId><artifactId>Utils4Java-parent</artifactId><packaging>pom</packaging><version>0.0.1-SNAPSHOT</version><name>Utils4Java-parent</name>
<url>http://maven.apache.org</url><modules><module>../encryption</module></modules><profiles><profile><id>run_build</id><properties><log4j.print.sys>false</log4j.print.sys></properties></profile><profile><id>dev_build</id><properties><log4j.print.sys>true</log4j.print.sys></properties></profile></profiles><repositories><repository><id>central</id><name>Central Repository</name><url>https://nexus.sourcesense.com/nexus/content/repositories/public/</url><layout>default</layout><snapshots><enabled>false</enabled></snapshots></repository></repositories><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><junit.version>4.10</junit.version></properties><dependencyManagement><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>${junit.version}</version><scope>test</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>2.3.2</version><configuration><source>1.7</source><target>1.7</target><showWarnings>true</showWarnings><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>2.1.2</version><executions><execution><goals><goal>jar</goal><goal>test-jar</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-eclipse-plugin</artifactId><version>2.8</version><configuration><wtpversion>2.0</wtpversion></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.3</version><configuration><archive><manifestEntries><Vendor>${project.organization.name}</Vendor><Artifact-Id>${project.artifactId}</Artifact-Id><Implementation-Version>${project.version}</Implementation-Version><Build>${project.build}</Build></manifestEntries></archive></configuration></plugin></plugins></build></project>

encryption项目中的pom文件例如以下:

<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/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.kxw</groupId><artifactId>Utils4Java-parent</artifactId><version>0.0.1-SNAPSHOT</version><relativePath>../Utils4Java-parent/pom.xml</relativePath></parent><artifactId>encryption</artifactId><packaging>jar</packaging><name>encryption</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><scope>test</scope></dependency></dependencies></project>

这样就能够在这基础上新建多个maven文件并依赖于父POM文件了。

二.用git管理项目代码

.gitignore文件:

.*.swp
.DS_Store
*target*
*.jar
*.war
*.ear
*.class
classes/
.svn
.classes
.project
.classpath
.settings/
.metadata
bin
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
.classpath
.settings/**
tartget/**git.properties

想了解怎样用git上传代码能够看这里:http://blog.csdn.net/kingson_wu/article/details/38436923

三.使用maven插件把项目变成eclipse项目

这些插件在父POM文件已经配置。仅仅有执行MavenEclipseBuild.bat就可以

cd Utils4Java-parent
call mvn eclipse:clean eclipse:eclipse pause

四.使用maven打包开发(測试)环境和正式环境

mavenProjectBuild.bat正式

cd Utils4Java-parent
call mvn clean install -Dmaven.test.skip=true -Prun_buildpause

mavenProjectBuild-Dev.bat开发

cd Utils4Java-parent
call mvn clean install -Dmaven.test.skip=true -Pdev_buildpause

parent的pom中:

<profiles><profile><id>run_build</id><properties><log4j.print.sys>false</log4j.print.sys></properties></profile><profile><id>dev_build</id><properties><log4j.print.sys>true</log4j.print.sys></properties></profile></profiles>

demo的源代码在:https://github.com/KingsonWu/Kingson4Blog/tree/master/MutipleEclipseMavenProjectDemo

-------------

又一次pull代码之后

先project build

再Eclipse build

然后 project clean(在Eclipse中)

注意:切完 分支之会后再次eclipse.bat,否则,它是依赖于旧。

版权声明:本文博主原创文章。博客,未经同意不得转载。

转载于:https://www.cnblogs.com/zfyouxi/p/4829711.html

怎么样eclipse发达国家多重聚合关系maven项目和使用git管理相关推荐

  1. GitChat · 软件工程 | 一小时教你学会 Maven 项目的构建与管理

    GitChat 作者:梁鹏举 原文: 一小时教你学会 Maven 项目的构建与管理 关注公众号:GitChat 技术杂谈,一本正经的讲技术 Maven翻译成中文是"专家.内行".M ...

  2. eclipse java maven_Eclipse构建maven项目

    Eclipse构建maven项目 1 Maven项目转为Eclipse项目 在项目的根目录下打开cmd:执行命令:mvn eclipse:eclipse :将会出现.classpath和.projec ...

  3. 7.Eclipse中创建新Maven项目

     第一步:首先导入前面命令行建立的两个maven项目Hello和HelloFriend. 方法:选择file-->import-->Existing MAVEN PROJECTS选项选 ...

  4. eclipse不识别java,在Eclipse中运行的Maven项目存在问题,无法识别为Java项目

    我已经将现有的maven项目导入Eclipse.我试图为JUnit测试设置配置,但是我的项目不会成为可测试项目.当我手动输入项目名称时,收到以下消息: 指定的项目不是Java项目 我还注意到,在键入代 ...

  5. Maven项目中的依赖管理——dependencyManagement

    在使用 Maven 创建多模块项目的时候,在父项目的 pom 文件中经常会碰见 <dependencyManagement> 标签的使用,比如如下代码: <dependencyMan ...

  6. android git提交整个项目_使用git管理嵌入式软件版本

    点击上方蓝字关注我哦- 你现在的Keil工程的版本控制是怎么管理的?可能有些人的做法是发布一个版本软件后将代码打一个包保存起来,作为此版本的备份.有一种常见的情况,当开始一项新功能的开发,并且最终的效 ...

  7. 初始化uniapp微信小程序项目并进行git管理

    1. 首先新建一个项目 2. 填写项目名称 ==> 选择 uni-ui项目 ==> 我这里是选择 vue2 版本, 最后点击创建即可 3. 将创建的项目运行起来 3.1 注意事项 (1)注 ...

  8. Eclipse创建一个普通maven项目详细步骤

    首先找到Eclipse最顶部左边的File,new一个 Maven Project项目 下一步,勾选第二个即可 下一步,选择  maven-archetype-webapp Group Id 写域名倒 ...

  9. Eclipse搭建SpringCloud+SSM+Maven项目

    1.使用的是eclipse 2.本次创建的是client端,server是已存在的 首先新创建一个Spring Starter Project 填写项目基本信息 选取项目需要的依赖(后期也可以在pom ...

  10. eclipse从svn导入maven项目变成普通项目解决办法

    右击项目-->configure-->Convert to Maven Project 转载于:https://www.cnblogs.com/zhanzhuang/p/9105463.h ...

最新文章

  1. Java实现反向输出链表
  2. IBatis.Net学习笔记五--常用的查询方式
  3. 文件共享服务器地址格式,文件共享服务器配置
  4. python 中BeautifulSoup入门
  5. 源代码电影涉及的计算机思想,关于电影源代码的结局解释
  6. JAVA day15 Collection(集合)、Iterator迭代器、泛型<E>
  7. 机器学习--线性回归1_线性回归-进入迷人世界的第一步
  8. sans serif字体_30种免费的Sans Serif字体下载
  9. java 跨平台的等宽字体_值得推荐的优秀编程字体/代码等宽字体收集(转)
  10. java 项目开发日报_CSDN日报191114:Java开发干货分享
  11. 西门子s1200教程_西门子S-1200入门PLC视频教程百度云资源下载
  12. 让 orangepi 用上Btsync(资源分享工具)好资源不怕和谐!
  13. lzg_ad: SQL SERVER2000安装问题
  14. 消息队列的优点和缺点
  15. 外部中断控制LED灯开关
  16. python如何模拟微信扫码登录_python 微信扫码登录故障解决
  17. 透过数字化转型再谈数据中台(三):一文遍历大数据架构变迁史
  18. LSB隐写(最低有效位隐写)
  19. 福岛第一核电站的辐射水平已明显下降
  20. MAX6951EEE+T LED显示驱动器MAXIM 共阴极显示驱动器

热门文章

  1. HazeOver For Mac(管理窗口工具)
  2. xxx.app 已损坏无法打开,来自身份不明的开发者解决方法
  3. CodeMix使用的语言和框架(一):JavaScript
  4. Apache启用GZIP压缩网页传输方法
  5. iphone4 通讯录数据库文件!
  6. 【转】 pycharm快捷键、常用设置、配置管理(后两者详见原博客)
  7. Navicat for MySQL再谈之无奈之下还是去安装Navicat Premium
  8. vim格式化代码实际上就是 缩进代码, 命令是等号=
  9. RestEasy传值方式
  10. [Asp.net]常见数据导入Excel,Excel数据导入数据库解决方案,总有一款适合你!