zoukankan      html  css  js  c++  java
  • maven+svn+jenkins(一)

    需求:

    1,在本机装好maven,nexus,通过maven构建三个项目,platform父项目,platform_db子项目(dao层工具包),platform_easyuiSSH子项目(web项目)

    2,装好svn,将项目发布到svn中

    3,装好jenkins,从svn导出项目打包,发布到服务器上

    执行步骤:

    一,maven构建项目

    1,官网下载maven,解压安装

    2,类似jdk一样配置mvn_home,在cmd上输入mvn -v指令验证路径是否正确

    3,maven的仓库默认都会在.m2下有一个Repository文件夹存放项目,jar包等数据,但是这里我自定义一个文件夹来存放,指向路径在maven/conf/settings.xml配置文件中更改,私服配置也在这里,到这一步maven就配置好了,如果你不使用eclipse等IDE开发,那么只要你的项目格式符合maven的标准,可以直接在cmd中使用命令构建发布

    <localRepository>D:/ProgramFiles/Repository/Mvn</localRepository>

    4,私服nexus安装有两种,一种是下载war,放在服务器,一种是下载绿色版本,使用快捷启动,这里下载绿色版本。

    在D:\ProgramFiles\Nexus\nexus-2.11.0-02\conf\nexus.properties配置端口号

    D:\ProgramFiles\Nexus\nexus-2.11.0-02\bin\jsw在该目录下根据系统不同找到启动bat

    http://localhost:8081/nexus访问地址默认密码是admin*admin123

    如果修改密码admin登录后,右上角点击profile,如果创建新账号,admin登录后,左边栏security-Users,私服中的jar包项目放在D:\ProgramFiles\Nexus\sonatype-work目录下,具体哪个仓库则是看你的配置和需求,百度都有相关介绍,这里就不一一介绍了。

    5,这时候我们需要将maven和私服关联起来,这样maven下载jar包就会先去私服,在由私服在本地或者中心仓库获取,配置和maven库存的路径一样,在conf\settings文件中

    nexus管理员密码用户名

    <server>
    <id>nexus-releases</id>
    <username>admin</username>
    <password>admin123</password>
    </server>

    <server>
    <id>nexus-snapshots</id>
    <username>admin</username>
    <password>admin123</password>
    </server>

    <mirror>/*Mirror是制定镜像站点*/
    <id>nexus</id>/*唯一标示*/
    <mirrorOf>*</mirrorOf>/*是被镜像的服务器的id。例如,如果我们要设置了一个Maven中央仓库(http:// repo1.maven.org/maven2)的镜像,就需要将该元素设置成central。这必须和 
    中央仓库的id central完全一致*/
    <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>/*该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL*/
    </mirror>

    <profile>
    <id>nexus</id>
    /*这个是设置中央仓库访问,如果私服没有打开或者通信出问题,项目会直接访问中央仓库,具体属性含义百度*/
    <repositories>
    <repository>
    <id>central</id>
    <url>http://central</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </repository>
    </repositories>

    <pluginRepositories>
    <pluginRepository>
    <id>central</id>
    <url>http://central</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </pluginRepository>
    </pluginRepositories>

    </profile>

    /*通过配置激活profile或者说nexus*/

    <activeProfiles>
    <activeProfile>nexus</activeProfile>
    </activeProfiles>

    6,打开eclipse,maven在eclipse上的插件是m2eclipse默认已经下载,只需在window-preferences中搜索maven,导入配置文件即可,之后maven会自动导入,如图

    7,之后像建立web项目一样,在file-new-other选择maven,建立项目platform,platform_db,platform_easyuiSSH,关联父项目有两种方式,一种是先建立父项目,之后再父项目上建立子项目,这样两个项目会自动关联起来,子项目的pom修改后,父项目也会自动更新,省掉了许多麻烦,一种是手动配置,因为开始我先把三个项目建好了,所以主要讲第二种。在我建好platform之后,我需要在父项目下按照maven格式手动建立子项目的文件,同时导入pom.xml,如果是web项目还需要导入web.xml,如果修改这两个配置文件,父项目也要手动更新,如图

    8,配置父项目的pom.xml,其实父项目什么都没有,主要是方便jar包的版本控制,同时子项目之间相互调用,主要是几个方面,

    8.1,项目版本坐标

    8.2,所有jar包依赖的版本号,以变量方式存储,便于管理

    8.3,依赖管理

    8.4,插件管理(包括jdk,资源,打包等等)

    8.5,发布管理,一般发布到私服

    8.6,子项目管理

    <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>
    <!-- maven插件版本控制 -->
    <groupId>com</groupId>
    <artifactId>platform</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>
    <name>platform Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <!-- 同一组件版本 -->
    <properties>
    <!-- ********************项目基本设置******************************** -->
    <!-- 项目编码 -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- JDK编码 -->
    <jdk.version>1.8</jdk.version>
    <!-- WEB项目根据路径 -->
    <webapp.path>src/main/webapp</webapp.path>
    <!-- WEB项目的class路径 -->
    <class.path>src/main/webapp/WEB-INF/classes</class.path>
    <!-- WEB项目的lib路径 -->
    <lib.path>src/main/webapp/WEB-INF/lib</lib.path>
    <!-- ***************************** J2EE环境 ***************************** -->
    <!-- servlet版本 -->
    <javax.servlet.servlet-api.version>3.0-alpha-1</javax.servlet.servlet-api.version>
    <!-- jsp版本 -->
    <javax.servlet.jsp.jsp-api.version>2.2.1-b03</javax.servlet.jsp.jsp-api.version>
    <!-- jstl版本 -->
    <jstl.jstl.version>1.2</jstl.jstl.version>

    <!-- ***************************** Maven插件 ***************************** -->
    <org.apache.maven.plugins.resources.version>2.7</org.apache.maven.plugins.resources.version>
    <org.apache.maven.plugins.source.version>2.4</org.apache.maven.plugins.source.version>
    <org.apache.maven.plugins.war.version>2.5</org.apache.maven.plugins.war.version>
    <org.apache.maven.plugins.dependency.version>2.9</org.apache.maven.plugins.dependency.version>
    <org.apache.maven.plugins.surefire.version>2.9</org.apache.maven.plugins.surefire.version>
    <org.apache.maven.plugins.compiler.version>3.2</org.apache.maven.plugins.compiler.version>

    <!-- ***************************** 第三方框架***************************** -->
    <!-- springframwork -->
    <org.springframework.version>3.2.9.RELEASE</org.springframework.version>
    <org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
    <!-- hibernate -->
    <org.hibernate.version>4.2.0.Final</org.hibernate.version>
    <!-- mybatis -->
    <org.mybatis.version>3.2.8</org.mybatis.version>
    <!-- mybatis-spring -->
    <org.mybatis.mybatis-spring.version>1.2.2</org.mybatis.mybatis-spring.version>
    <!-- dwr -->
    <org.directwebremoting.dwr.version>3.0.0-rc3-RELEASE</org.directwebremoting.dwr.version>
    <!-- json -->
    <net.sf.json-lib.version>2.4</net.sf.json-lib.version>
    <net.sf.ezmorph.version>1.0.6</net.sf.ezmorph.version>
    <!-- quartz -->
    <org.quartz-scheduler.quartz.version>2.2.1</org.quartz-scheduler.quartz.version>
    <!-- apache -->
    <org.apache.struts1.version>1.3.10</org.apache.struts1.version>
    <org.apache.struts2.version>2.3.16.3</org.apache.struts2.version>
    <org.apache.poi.version>3.11-beta3</org.apache.poi.version>
    <org.apache.ant.version>1.9.4</org.apache.ant.version>
    <!-- apache-commons -->
    <org.apache.commons-lang3.version>3.3.2</org.apache.commons-lang3.version>
    <commons-io.version>2.4</commons-io.version>
    <commons-collections.version>3.2.1</commons-collections.version>
    <commons-codec.version>1.9</commons-codec.version>
    <commons-beanutils.version>1.9.2</commons-beanutils.version>
    <commons-logging.version>1.2</commons-logging.version>
    <commons-fileupload.version>1.3.1</commons-fileupload.version>
    <commons-net.version>3.3</commons-net.version>
    <commons-configuration.version>1.10</commons-configuration.version>
    <commons-compress.version>1.9</commons-compress.version>
    <commons-dbcp.version>1.4</commons-dbcp.version>
    <commons-httpclient.version>3.1</commons-httpclient.version>
    <commons-validator.version>1.4.0</commons-validator.version>
    <commons-math3.version>3.4.1</commons-math3.version>
    <commons-pool.version>1.6</commons-pool.version>
    <commons-exec.version>1.3</commons-exec.version>
    <commons-digester.version>2.0</commons-digester.version>
    <commons-chain.version>1.2</commons-chain.version>
    <bsf.version>2.4.0</bsf.version>
    <!-- test -->
    <junit.version>4.11</junit.version>
    <!-- log -->
    <org.slf4j-api.version>1.7.10</org.slf4j-api.version>
    <org.slf4j-simple.version>1.7.10</org.slf4j-simple.version>
    <org.slf4j-log4j12.version>1.7.10</org.slf4j-log4j12.version>
    <log4j.version>1.2.17</log4j.version>
    <ch.qos.logback.version>1.1.2</ch.qos.logback.version>
    <!-- pool -->
    <com.mchange.c3p0.version>0.9.5</com.mchange.c3p0.version>
    <com.cloudhopper.proxool.version>0.9.1</com.cloudhopper.proxool.version>
    <!-- connection -->
    <mysql-connector-java.version>5.1.34</mysql-connector-java.version>
    <oracle-ojdbc6.version>11.2.0.3.0</oracle-ojdbc6.version>
    <com.microsoft.sqlserver.sqljdbc4.version>4.0</com.microsoft.sqlserver.sqljdbc4.version>
    <!-- alibaba -->
    <com.alibaba.fastjson.version>1.2.4</com.alibaba.fastjson.version>
    <com.alibaba.dubbo.version>2.5.3</com.alibaba.dubbo.version>
    <com.alibaba.druid.version>1.0.13</com.alibaba.druid.version>
    <!-- dom -->
    <dom4j.version>1.6.1</dom4j.version>
    <jdom2.version>2.0.6</jdom2.version>
    <!-- joda -->
    <joda-time.version>2.7</joda-time.version>
    <joda-convert.version>1.7</joda-convert.version>
    <joda-time-jsptags.version>1.1.1</joda-time-jsptags.version>
    <!-- belerweb -->
    <com.belerweb.pinyin4j.version>2.5.0</com.belerweb.pinyin4j.version>
    <!-- aspectj -->
    <org.aspectj.aspectjweaver.version>1.8.5</org.aspectj.aspectjweaver.version>
    </properties>

    <!-- 统一依赖管理 -->
    <dependencyManagement>
    <dependencies>
    <!-- test -->
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>${junit.version}</version>
    </dependency>
    <!-- J2EE环境 -->
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>${javax.servlet.servlet-api.version}</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <version>${javax.servlet.jsp.jsp-api.version}</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>${jstl.jstl.version}</version>
    </dependency>
    <!-- springframwork -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>
    <!-- spring-security -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>${org.springframework.security.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>${org.springframework.security.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>${org.springframework.security.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-cas</artifactId>
    <version>${org.springframework.security.version}</version>
    </dependency>
    <!-- hibernate -->
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>${org.hibernate.version}</version>
    </dependency>
    <!-- mybatis -->
    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>${org.mybatis.version}</version>
    </dependency>
    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>${org.mybatis.mybatis-spring.version}</version>
    </dependency>
    <!-- apache -->
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>${org.apache.struts2.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    <version>${org.apache.struts2.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    <version>${org.apache.struts2.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-json-plugin</artifactId>
    <version>${org.apache.struts2.version}</version>
    </dependency>
    <!-- Struts1导入开始 -->
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts-el</artifactId>
    <version>${org.apache.struts1.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts-core</artifactId>
    <version>${org.apache.struts1.version}</version>
    </dependency>
    <!-- 引入dispatchAction等高级Action-->
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts-extras</artifactId>
    <version>${org.apache.struts1.version}</version>
    </dependency>
    <!-- Struts1导入结束 -->
    <dependency>
    <groupId>org.apache.ant</groupId>
    <artifactId>ant</artifactId>
    <version>${org.apache.ant.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>${org.apache.poi.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>${org.apache.poi.version}</version>
    </dependency>
    <!-- Apache-Commons -->
    <dependency>
    <groupId>commons-digester</groupId>
    <artifactId>commons-digester</artifactId>
    <version>${commons-digester.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-chain</groupId>
    <artifactId>commons-chain</artifactId>
    <version>${commons-chain.version}</version>
    </dependency>
    <dependency>
    <groupId>bsf</groupId>
    <artifactId>bsf</artifactId>
    <version>${bsf.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>${org.apache.commons-lang3.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>${commons-io.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>${commons-collections.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>${commons-codec.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-beanutils</groupId>
    <artifactId>commons-beanutils</artifactId>
    <version>${commons-beanutils.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>${commons-logging.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>${commons-fileupload.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-configuration</groupId>
    <artifactId>commons-configuration</artifactId>
    <version>${commons-configuration.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-compress</artifactId>
    <version>${commons-compress.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-net</groupId>
    <artifactId>commons-net</artifactId>
    <version>${commons-net.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>${commons-dbcp.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-httpclient</groupId>
    <artifactId>commons-httpclient</artifactId>
    <version>${commons-httpclient.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-validator</groupId>
    <artifactId>commons-validator</artifactId>
    <version>${commons-validator.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-math3</artifactId>
    <version>${commons-math3.version}</version>
    </dependency>
    <dependency>
    <groupId>commons-pool</groupId>
    <artifactId>commons-pool</artifactId>
    <version>${commons-pool.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-exec</artifactId>
    <version>${commons-exec.version}</version>
    </dependency>
    <!-- 日志 -->
    <!-- slf4j -->
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>${org.slf4j-api.version}</version>
    </dependency>
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>${org.slf4j-simple.version}</version>
    </dependency>
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>${org.slf4j-api.version}</version>
    </dependency>
    <!-- log4j -->
    <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>${log4j.version}</version>
    </dependency>
    <!-- logback -->
    <dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>${ch.qos.logback.version}</version>
    </dependency>
    <dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-core</artifactId>
    <version>${ch.qos.logback.version}</version>
    </dependency>
    <dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-access</artifactId>
    <version>${ch.qos.logback.version}</version>
    </dependency>
    <!-- 连接池 -->
    <dependency>
    <groupId>com.mchange</groupId>
    <artifactId>c3p0</artifactId>
    <version>${com.mchange.c3p0.version}</version>
    </dependency>
    <dependency>
    <groupId>com.cloudhopper.proxool</groupId>
    <artifactId>proxool</artifactId>
    <version>${com.cloudhopper.proxool.version}</version>
    </dependency>
    <!-- jdbc-connection -->
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>${mysql-connector-java.version}</version>
    </dependency>
    <dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>${oracle-ojdbc6.version}</version>
    </dependency>
    <dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc4</artifactId>
    <version>${com.microsoft.sqlserver.sqljdbc4.version}</version>
    </dependency>
    <!-- alibaba -->
    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>${com.alibaba.fastjson.version}</version>
    </dependency>
    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>${com.alibaba.dubbo.version}</version>
    </dependency>
    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>${com.alibaba.druid.version}</version>
    </dependency>
    <!-- dom -->
    <dependency>
    <groupId>dom4j</groupId>
    <artifactId>dom4j</artifactId>
    <version>${dom4j.version}</version>
    </dependency>
    <dependency>
    <groupId>org.jdom</groupId>
    <artifactId>jdom2</artifactId>
    <version>${jdom2.version}</version>
    </dependency>
    <!-- joda -->
    <dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
    <version>${joda-time.version}</version>
    </dependency>
    <dependency>
    <groupId>org.joda</groupId>
    <artifactId>joda-convert</artifactId>
    <version>${joda-convert.version}</version>
    </dependency>
    <dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time-jsptags</artifactId>
    <version>${joda-time-jsptags.version}</version>
    </dependency>
    <!-- dwr -->
    <dependency>
    <groupId>org.directwebremoting</groupId>
    <artifactId>dwr</artifactId>
    <version>${org.directwebremoting.dwr.version}</version>
    </dependency>
    <!-- json-lib -->
    <dependency>
    <groupId>net.sf.json-lib</groupId>
    <artifactId>json-lib</artifactId>
    <version>${net.sf.json-lib.version}</version>
    <classifier>jdk15</classifier>
    </dependency>
    <dependency>
    <groupId>net.sf.ezmorph</groupId>
    <artifactId>ezmorph</artifactId>
    <version>${net.sf.ezmorph.version}</version>
    </dependency>
    <!-- quartz -->
    <dependency>
    <groupId>org.quartz-scheduler</groupId>
    <artifactId>quartz</artifactId>
    <version>${org.quartz-scheduler.quartz.version}</version>
    </dependency>
    <!-- other -->
    <dependency>
    <groupId>com.belerweb</groupId>
    <artifactId>pinyin4j</artifactId>
    <version>${com.belerweb.pinyin4j.version}</version>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>${org.aspectj.aspectjweaver.version}</version>
    </dependency>
    </dependencies>
    </dependencyManagement>
    <!-- 统一插件管理 -->
    <build>
    <pluginManagement>
    <plugins>
    <!-- 资源 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>${org.apache.maven.plugins.resources.version}</version>
    </plugin>
    <!-- 编译 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${org.apache.maven.plugins.compiler.version}</version>
    <configuration>
    <source>${jdk.version}</source>
    <target>${jdk.version}</target>
    <encoding>${project.build.sourceEncoding}</encoding>
    </configuration>
    </plugin>
    <!-- 源码打包 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>${org.apache.maven.plugins.source.version}</version>
    <configuration>
    <!-- 导入pom文件 -->
    <includePom>true</includePom>
    <!-- 每次都重新创 -->
    <forceCreation>true</forceCreation>
    </configuration>
    <executions>
    <execution>
    <id>jar-no-fork</id>
    <phase>install</phase>
    <goals>
    <goal>jar-no-fork</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    <!-- war -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>${org.apache.maven.plugins.war.version}</version>
    </plugin>
    <!-- 依赖 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>${org.apache.maven.plugins.dependency.version}</version>
    <configuration>
    <outputDirectory>${lib.path}</outputDirectory>
    </configuration>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${org.apache.maven.plugins.surefire.version}</version>
    <configuration>
    <skip>true</skip>
    </configuration>
    </plugin>
    </plugins>
    </pluginManagement>
    </build>
    <!-- 统一发布管理 -->
    <distributionManagement>
    <repository>
    <id>nexus-releases</id>
    <name>Nexus Release Repository</name>
    <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
    <id>nexus-snapshots</id>
    <name>Nexus Snapshot Repository</name>
    <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
    </distributionManagement>
    <modules>
    <module>platform_core</module>
    <module>platform_db</module>
    <module>platform_easyuiSSH</module>
    </modules>
    </project>

    9,platform_db的配置,依次是主目录,测试,资源,pom配置

    配置上需要注意的是手动配置在导入父项目坐标需要配置pom.xml的相对路径,然后需要什么导入什么

    <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>

    <parent>
    <groupId>com</groupId>
    <artifactId>platform</artifactId>
    <version>1.0</version>
    <relativePath>../platform/pom.xml</relativePath>
    </parent>

    <artifactId>platform_db</artifactId>
    <packaging>jar</packaging>
    <name>platform_db Maven</name>
    <url>http://maven.apache.org</url>

    <!-- 依赖配置 -->
    <dependencies>
    <!-- 测试 -->
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>test</scope>
    </dependency>
    <!-- druid数据连接池 -->
    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    </dependency>
    <!-- mysql驱动 -->
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    </dependency>
    </dependencies>
    <!-- 统一插件管理 -->
    <build>
    <finalName>platform_db</finalName>

    <pluginManagement>
    <plugins>
    <plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
    <configuration>
    <lifecycleMappingMetadata>
    <pluginExecutions>
    <pluginExecution>
    <pluginExecutionFilter>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <versionRange>[2.0,)</versionRange>
    <goals>
    <goal>copy-dependencies</goal>
    </goals>
    </pluginExecutionFilter>
    <action>
    <ignore />
    </action>
    </pluginExecution>
    </pluginExecutions>
    </lifecycleMappingMetadata>
    </configuration>
    </plugin>
    </plugins>
    </pluginManagement>

    <plugins>
    <!-- 编译 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    </plugin>
    <!-- 资源 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    </plugin>
    <!-- dependency -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
    <execution>
    <id>copy-dependencies</id>
    <phase>package</phase>
    <goals>
    <goal>copy-dependencies</goal>
    </goals>
    <configuration>
    <!-- lib输出目录 -->
    <outputDirectory>${lib.path}</outputDirectory>
    <!-- 不需要导入的范围 -->
    <excludeScope>provided</excludeScope>
    </configuration>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>
    </project>

    platform_easyuiSSH没有什么太大区别,主要是多了web路径,还有jar包配置改为war,同时该项目为了访问数据库需要调用platform_db,将platform_db当成jar包访问就好了,在依赖中配置它的坐标

    注意目录一定要有lib用来放jar包

    <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</groupId>
    <artifactId>platform</artifactId>
    <version>1.0</version>
    <relativePath>../platform/pom.xml</relativePath>
    </parent>

    <artifactId>platform_easyuiSSH</artifactId>

    <packaging>war</packaging>

    <name>platform_easyuiSSH Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <!-- 依赖配置 -->
    <dependencies>
    <!-- 依赖db子模块操作数据库 -->
    <dependency>
    <groupId>com</groupId>
    <artifactId>platform_db</artifactId>
    <version>1.0</version>
    </dependency>
    <!-- 依赖servlet -->
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>test</scope>
    </dependency>
    <!-- Struts1导入开始 -->
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts-el</artifactId>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts-core</artifactId>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts-extras</artifactId>
    </dependency>
    <!-- Struts1导入结束 -->
    <!-- Apache-Commons -->
    <dependency>
    <groupId>bsf</groupId>
    <artifactId>bsf</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-digester</groupId>
    <artifactId>commons-digester</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-beanutils</groupId>
    <artifactId>commons-beanutils</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-validator</groupId>
    <artifactId>commons-validator</artifactId>
    </dependency>
    </dependencies>
    <!-- 统一插件管理 -->
    <build>
    <finalName>platform-easyuiSSH</finalName>
    <outputDirectory>${class.path}</outputDirectory>
    <testOutputDirectory>${class.path}</testOutputDirectory>

    <pluginManagement>
    <plugins>
    <plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
    <configuration>
    <lifecycleMappingMetadata>
    <pluginExecutions>
    <pluginExecution>
    <pluginExecutionFilter>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <versionRange>[2.0,)</versionRange>
    <goals>
    <goal>copy-dependencies</goal>
    </goals>
    </pluginExecutionFilter>
    <action>
    <ignore />
    </action>
    </pluginExecution>
    </pluginExecutions>
    </lifecycleMappingMetadata>
    </configuration>
    </plugin>
    </plugins>
    </pluginManagement>

    <plugins>
    <!-- 编译 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    </plugin>
    <!-- 资源 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    </plugin>
    <!-- war -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
    <!-- <warName>${profiles.activation}</warName> -->
    <!-- 激活spring profile -->
    <webResources>
    <resource>
    <filtering>true</filtering>
    <directory>src/main/webapp</directory>
    <includes>
    <include>**/web.xml</include>
    </includes>
    </resource>
    </webResources>
    <warSourceDirectory>src/main/webapp</warSourceDirectory>
    <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
    </configuration>
    </plugin>
    <!-- dependency -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
    <execution>
    <id>copy-dependencies</id>
    <phase>package</phase>
    <goals>
    <goal>copy-dependencies</goal>
    </goals>
    <configuration>
    <!-- lib输出目录 -->
    <outputDirectory>${lib.path}</outputDirectory>
    <!-- 不需要导入的范围 -->
    <excludeScope>provided</excludeScope>
    </configuration>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>
    </project>

    10,项目建好后需要执行一下指令

    platform-deploy发布到私服

    platform_db-install构建项目(发布在本地)

    platform_db-deploy发布到私服(dao层项目开发完了打成jar包发布到服务器,方便其它项目调用)

    platform_easyuiSSH-package打包

    11,之后再上面开发就好,下一步就是安装svn,方便项目版本管理和Jenkins调用。

  • 相关阅读:
    两种&
    安装版Windows是必须的
    检验CSS3.0兼容性的有趣东东
    Quadro和Geforce系列的区别
    ECMAScript
    多拉A梦的CSS(6) :not
    多拉A梦的CSS(1) Transform
    表单
    关于a元素的伪类
    多拉A梦的CSS(4) gradient
  • 原文地址:https://www.cnblogs.com/lbblog/p/4705411.html
Copyright © 2011-2022 走看看