zoukankan      html  css  js  c++  java
  • maven 使用

    TIPs:在maven 3.0.5之后,archetype:create命令不在使用,取而代之的是archetype:generate命令

    只是简单记录 一些重点

    1,下载

    2,配置环境变量,(这里是不是必须配置,答案是NO, 但是一般建议配置)

    3,重点,修改setting文件,apache-maven-3.0.3/conf/setting.xml中

      添加 <localRepository>D:MavenTestmaven epos</localRepository> 

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
    
    
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
      <!-- localRepository
       | The path to the local repository maven will use to store artifacts.
       |
       | Default: ~/.m2/repository -->
      <localRepository>D:MavenTestmaven
    epos </localRepository>

    默认位置是C:**.m2 epository,如果我们不指定的话,就在这个位置。

    但是这样不便于管理,建议设定为指定位置!

    4,  重点,这里选择阿里云的镜像仓库,速度会快很多!

     <mirrors>
        <!-- mirror
         | Specifies a repository mirror site to use instead of a given repository. The repository that
         | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
         | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
         |
        <mirror>
          <id>mirrorId</id>
          <mirrorOf>repositoryId</mirrorOf>
          <name>Human Readable Name for this Mirror.</name>
          <url>http://my.repository.com/repo/path</url>
        </mirror>
         -->
      <mirror>
          <id>alimaven</id>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>        
        </mirror>
         
      </mirrors>

    这样,就可以在cmd中使用mvn 命令创建,编译,打包,等等操作,管理项目了

    **************************************

    5,eclipse 版本中已经集成了maven,但是我们不建议使用集成的插件,一般选择指定的插件,(PS:这里可以查看,指定eclipse中使用的setting.xml文件所在的位置,修改这个文件的 本地仓库,和下载镜像)。

    6,Maven使用中,由于部分jar不支持,需要手工导入到 本地厂库中,常用的入 ojdbc14.jar。

    导入方式:

    1,下载ojdbc14.jar到本地路径 eg:D:/extJar/ojdbc14.jar

    下载ojdbc14包,并在命令行中执行如下语句:

    mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar -Dfile=D:/extJar/ojdbc14.jar

    注意其中的参数,即为调用的参数;

    2, 在pom文件中使用如下引用;

    <dependency>
      <groupid>com.oracle</groupid>
      <artifactid>ojdbc14</artifactid>
      <version>10.2.0.4.0</version>
    </dependency>

    3,查看  .. epositorycomoracleojdbc1410.2.0.4.0下找到包ojdbc14-10.2.0.4.0.jar,刷新项目,即可显示成功。

    ps: 如果 mven install:install-file 提示找不到jar等错误,是maven配置不完全正确导致。
    一,保证mvn -version 正常显示;
    二,cd 到 .jar 文件的所在位置

    然后  mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar -Dfile= ojdbc14.jar,
    写当前路径.

    4:

    compile的时候,如果有配置文件
     包括resources下的配置文件
            和*.sqlMapper.xml配置文件等

    编译在target中加上这些配置文件,需要添加

    <build>
    
    <resources> 
       <resource> 
        <directory>src/main/java</directory> 
          <includes> 
            <include>**/*SqlMap.xml</include> 
          </includes> 
      </resource>
      <resource> 
       <directory>src/main/resource</directory> 
        <includes> 
          <include>**/*</include> 
        </includes> 
     </resource> 
    </resources>
    </build>
    多想,多试
  • 相关阅读:
    WinCE NAND flash
    正确选择报表工具的十大标准
    从技术岗位走向管理岗位:机会是留给有准备的人
    创业失败的七个原因及解决之道
    技术人员如何参与产品设计讨论:激活那一潭死水
    基于Android Studio搭建hello world工程
    基于Android Studio搭建Android应用开发环境
    JS数组去重的6种算法实现
    八款前端开发人员更轻松的实用在线工具
    海市蜃楼-嘉兴外蒲岛奇遇
  • 原文地址:https://www.cnblogs.com/junyi0120/p/6110438.html
Copyright © 2011-2022 走看看