posts - 6,  comments - 15,  trackbacks - 0

          9 安裝[install]
          mvn install
          會將package之后的jar包copy到
          <local-repository>/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.jar

          10 其他
          mvn site
          ?注意:還可以deploy site
          ?在pom.xml中加入

          ? < distributionManagement >
          ???
          < site >
          ?????
          < id > website </ id > ???
          ?????? ?
          < url > scp://www.mycompany.com/www/docs/project/ </ url >
          ???
          </ site >
          ?
          </ distributionManagement >


          當然你需要設置server
          mvn site-deploy
          mvn clean
          mvn idea:idea [為IDE工具idea生成項目文件]

          11 Resource
          ${basedir}/src/main/resources都會編譯到jar文件中
          而${basedir}/src/main/resources 下的內容會直接位于jar文件的頂部
          測試用資源文件-> ${basedir}/src/test/resources
          引用時參照此例:
          InputStream is = getClass().getResourceAsStream( "/test.properties" );
          文件位于 ${basedir}/src/test/resources/test.properties。

          12 如何filter我們的資源文件
          在pom.xml中修改:

          < build >
          ????
          < resources >
          ??????
          < resource >
          ????????
          < directory > src/main/resources </ directory >
          ????????
          < filtering > true </ filtering >
          ??????
          </ resource >
          ????
          </ resources >
          ??
          </ build >


          因為原來默認的filter為false所以要加上上面的代碼
          e.g
          我們在src/main/resources下面建立application.properties文件
          ?# application.properties
          ?application.name=${pom.name}
          ?application.version=${pom.version}
          運行:mvn process-resources
          在target/classes下面,
          application.properties:
          ?# application.properties
          ?application.name=Maven Quick Start Archetype
          ?application.version=1.0-SNAPSHOT
          這就是所謂的filter.
          當然filter還可以用其他的外部文件,不一定來自pom.xml[ ${pom.name} ]以及setting.xml[ ${settings.localRepository }]
          e.g
          src/main/filters/filter.properties
          ?# filter.properties
          ?my.filter.value=hello!
          pom.xml

          ?? < build >
          ????
          < filters >
          ??????
          < filter > src/main/filters/filter.properties </ filter >
          ????
          </ filters >
          ????
          < resources >
          ??????
          < resource >
          ????????
          < directory > src/main/resources </ directory >
          ????????
          < filtering > true </ filtering >
          ??????
          </ resource >
          ????
          </ resources >
          ??
          </ build >


          # application.properties
          application.name=${pom.name}
          application.version=${pom.version}
          message=${my.filter.value}
          這樣在運行mvn process-resources 會得到類似的效果。

          當然我們也可以直接在pom.xml中定義:

          < build >
          ????
          < resources >
          ??????
          < resource >
          ????????
          < directory > src/main/resources </ directory >
          ????????
          < filtering > true </ filtering >
          ??????
          </ resource >
          ????
          </ resources >
          ??
          </ build >
          ??
          < properties >
          ????
          < my .filter.value > hello </ my.filter.value >
          ??
          </ properties >


          效果同樣,這樣就不需要外部文件了

          另外filter還可以來自系統設置以及可以自定義:
          # application.properties
          java.version=${java.version}
          command.line.prop=${command.line.prop}

          posted on 2006-03-28 14:46 jbob 閱讀(1488) 評論(0)  編輯  收藏 所屬分類: maven

          <2006年3月>
          2627281234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          生活感悟

          順手

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 铁岭市| 陆丰市| 宣化县| 芷江| 莆田市| 江津市| 吐鲁番市| 华宁县| 志丹县| 清新县| 荣成市| 陵水| 绥宁县| 阜南县| 工布江达县| 乐都县| 定远县| 邵阳县| 凉山| 宣城市| 宝鸡市| 外汇| 偃师市| 贵定县| 景东| 宁武县| 兴化市| 瑞昌市| 龙海市| 建瓯市| 永康市| 巨野县| 渝中区| 绵竹市| 冷水江市| 百色市| 宿州市| 高淳县| 抚顺县| 西乡县| 汝南县|