• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大龍的博客

            常用鏈接

            統(tǒng)計

            最新評論

            Maven POM 配置技巧

            Java代碼  收藏代碼
            1. 一、排除傳遞依賴的某個jar,以避免版本沖突。例如: 開發(fā)工程中需要引用struts2(2.0.11.2)和freemarker(2.3.16),但該struts2默認(rèn)依賴的是freemarker(2.3.8),可參考以下方式編寫:  
            2.   
            3. view plain  
            4. <dependency>    
            5.     <groupId>org.apache.struts</groupId>    
            6.     <artifactId>struts2-core</artifactId>    
            7.     <version>2.0.11.2</version>    
            8.     <type>jar</type>    
            9.     <scope>compile</scope>    
            10.     <exclusions>    
            11.       <exclusion> <!-- 排除freemarker,以避免版本沖突 -->    
            12.     <groupId>freemarker</groupId>    
            13.     <artifactId>freemarker</artifactId>    
            14.    </exclusion>    
            15.  </exclusions>    
            16. </dependency>    
            17. <dependency>    
            18.     <groupId>org.freemarker</groupId>    
            19.     <artifactId>freemarker</artifactId>    
            20.     <version>2.3.16</version>    
            21.     <type>jar</type>    
            22.     <scope>compile</scope>    
            23. </dependency>    
            24.    
            25.   
            26.    
            27.   
            28. 二、發(fā)布jar包同時發(fā)布源碼  
            29.   
            30. view plain  
            31.     <plugin>    
            32. <groupId>org.apache.maven.plugins</groupId>    
            33. <artifactId>maven-source-plugin</artifactId>    
            34. <version>2.1.2</version>    
            35. <configuration>    
            36.     <attach>true</attach>    
            37. </configuration>    
            38. <executions>    
            39.     <execution>    
            40.         <phase>compile</phase>    
            41.         <goals>    
            42.             <goal>jar</goal>    
            43.         </goals>    
            44.     </execution>    
            45. </executions>             
            46.     </plugin>    
            47.    
            48.   
            49.    
            50.   
            51. 三、Eclipse開發(fā)時,為方便使用內(nèi)置tomcat調(diào)試,需將所依賴的jar包復(fù)制到WEB-INF/lib目錄下。可通過以下配置:  
            52.   
            53. view plain  
            54. <plugin>    
            55.     <groupId>org.apache.maven.plugins</groupId>    
            56.     <artifactId>maven-dependency-plugin</artifactId>    
            57.     <version>2.1</version>    
            58.     <executions>    
            59.            <execution>    
            60.                <id>copy</id>    
            61.                <phase>package</phase>    
            62.                <goals>    
            63.                    <goal>copy-dependencies</goal>    
            64.                </goals>    
            65.                <configuration>    
            66.                    <outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory>    
            67.                </configuration>    
            68.            </execution>    
            69.         </executions>     
            70. </plugin>    
            71.    
            72. 配置完成后。每次有添加jar包依賴時,需運行一次mvn package命令。  
            73.   
            74.    
            75.   
            76.    
            77.   
            78. 四、有時工程中想復(fù)用其它工程中的靜態(tài)內(nèi)容(image/css/js),為方便開發(fā)調(diào)試,需將相應(yīng)的靜態(tài)內(nèi)容,解壓縮到當(dāng)前工程的webapp目錄下。可通過以下配置:  
            79. view plain  
            80. <plugin>    
            81.     <groupId>org.apache.maven.plugins</groupId>    
            82.     <artifactId>maven-dependency-plugin</artifactId>    
            83.     <version>2.1</version>    
            84.     <executions>    
            85.            <execution>    
            86.                <id>copy-statics</id>    
            87.                <phase>generate-resources</phase>    
            88.                <goals>    
            89.                    <goal>unpack</goal>    
            90.                </goals>    
            91.                <configuration>    
            92.                 <artifactItems>    
            93.               <artifactItem>    
            94.         <groupId>com.yihaodian.front</groupId>    
            95.         <artifactId>front-global</artifactId>    
            96.         <version>1.0-SNAPSHOT</version>    
            97.         <classifier>statics</classifier>    
            98.         <type>zip</type>    
            99.                  <overWrite>true</overWrite>    
            100.                  <outputDirectory>src/main/webapp</outputDirectory>    
            101.               </artifactItem>    
            102.             </artifactItems>    
            103.                </configuration>    
            104.            </execution>    
            105.         </executions>    
            106. </plugin>    
            107.    
            108.   
            109. 配置完成后,需運行一次mvn generate-resources命令。 

            posted on 2012-08-31 10:25 大龍 閱讀(1253) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            精品国产乱码久久久久软件| 久久精品人人做人人爽电影| 国内精品久久久久影院亚洲| 亚洲一级Av无码毛片久久精品| 欧美伊人久久大香线蕉综合| 亚洲午夜久久久久久久久电影网| 国产精品女同久久久久电影院| 99久久综合狠狠综合久久| 四虎久久影院| 99久久人妻无码精品系列 | 99久久中文字幕| 久久五月精品中文字幕| 亚洲AV日韩精品久久久久久| 26uuu久久五月天| 亚洲精品乱码久久久久久自慰| 国产精品福利一区二区久久| 亚洲欧美日韩精品久久亚洲区| 精品久久久久久久无码| 久久国产V一级毛多内射| 色狠狠久久AV五月综合| 国产精品热久久无码av| 日韩精品久久无码人妻中文字幕| 九九久久精品无码专区| 97久久天天综合色天天综合色hd| 亚洲精品无码久久不卡| 国产AV影片久久久久久| 久久99免费视频| 色8久久人人97超碰香蕉987| 一本色道久久88综合日韩精品| 91亚洲国产成人久久精品网址| 日日躁夜夜躁狠狠久久AV| 久久人人爽人人爽人人片AV不 | 精品久久久久久国产免费了| 亚洲国产另类久久久精品黑人| 久久久久亚洲爆乳少妇无| 香蕉久久一区二区不卡无毒影院| AV无码久久久久不卡蜜桃| 性做久久久久久久久| 久久婷婷五月综合成人D啪| 青青青伊人色综合久久| 久久伊人精品青青草原高清|