需求:java
1,在本機裝好maven,nexus,經過maven構建三個項目,platform父項目,platform_db子項目(dao層工具包),platform_easyuiSSH子項目(web項目)mysql
2,裝好svn,將項目發佈到svn中web
3,裝好jenkins,從svn導出項目打包,發佈到服務器上spring
執行步驟:sql
一,maven構建項目數據庫
1,官網下載maven,解壓安裝apache
2,相似jdk同樣配置mvn_home,在cmd上輸入mvn -v指令驗證路徑是否正確json
3,maven的倉庫默認都會在.m2下有一個Repository文件夾存放項目,jar包等數據,可是這裏我自定義一個文件夾來存放,指向路徑在maven/conf/settings.xml配置文件中更改,私服配置也在這裏,到這一步maven就配置好了,若是你不使用eclipse等IDE開發,那麼只要你的項目格式符合maven的標準,能夠直接在cmd中使用命令構建發佈api
<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調用。