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 閱讀(1489) 評論(0)  編輯  收藏 所屬分類: maven

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

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          生活感悟

          順手

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 新民市| 贺兰县| 建瓯市| 乌拉特中旗| 新安县| 仲巴县| 股票| 蒙阴县| 松滋市| 大理市| 呈贡县| 内黄县| 黑山县| 靖边县| 浠水县| 五原县| 定结县| 竹山县| 且末县| 安陆市| 贡觉县| 潍坊市| 稻城县| 壶关县| 长垣县| 洱源县| 栾城县| 垦利县| 犍为县| 澄城县| 新沂市| 嘉祥县| 洛川县| 太白县| 赫章县| 广东省| 信阳市| 乌兰浩特市| 绥滨县| 玉门市| 苍梧县|