maven学习2

来源:互联网 发布:sql server 2000数据库 编辑:程序博客网 时间:2024/06/03 16:16

maven安装注意事项

  • 修改maven本地仓库的默认存放路径

修改setting.xml
settings.xml所造路径为:maven安装路径\conf\setting.xml,例如H:\java_develop\apache-maven-3.3.3-bin\apache-maven-3.3.3\conf\setting.xml). maven本地仓库默认目录为user.home{user.home}是指“我的文档”。

<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: ${user.home}/.m2/repository  <localRepository>/path/to/local/repo</localRepository>  -->

修改为本地其他目录,如下:

<localRepository>G:\maven\repository</localRepository>

同时,复制修改后的setting.xml至G:\maven\repository路径下

  • 远程中央仓库设置

    maven安装路径\lib\maven-model-builder-3.3.3.jar包中可以查看到远程中央仓库的地址。
    解压jar后

打开pom-4.0.0.xml,如下代码片中URL标签即为中央仓库地址

<repositories>    <repository>      <id>central</id>      <name>Central Repository</name>      <url>https://repo.maven.apache.org/maven2</url>      <layout>default</layout>      <snapshots>        <enabled>false</enabled>      </snapshots>    </repository>  </repositories>

使用浏览器打开https://repo.maven.apache.org/maven2,可以查询到项目中所有依赖的第三方jar包。

  • maven骨架工具

    由于maven项目的目录结构是固定的,由此可以通过mvn archetype命令创建maven工程

mvn archetype: generate -DgroupId=com.zch.maven
-DartifactId=maven01 -Dversion=1.0-SNAPSHOT

  • eclipse中配置maven插件
    参考如下链接中5~9步
    http://jingyan.baidu.com/article/60ccbceb01de4d64cbb19756.html
0 0
原创粉丝点击