Maven 配置

  Maven:优秀的构建工具

  依赖java

一、下载

  maven:官网,http://maven.apache.org/

  maven3.1.1:http://maven.apache.org/download.cgi

二、解压,例如:D:\apache-maven-3.1.1

三、配置环境变量

  MAVEN_HOME:D:\apache-maven-3.1.1

  MAVEN:%MAVEN_HOME%\bin

  MAVEN_OPTS:-Xms256m -Xmx512m  (可选)

  添加到path:%MAVEN%

  检测是否成功 cmd.exe    ---->   mvn -version

四、配置maven配置文件、项目

  1、修改m2的配置目录D:\apache-maven-3.1.1\bin\m2.conf

  set maven.home default ${user.home}/m2  ------>set maven.home default ${maven.home}/m2

  默认为当前用户,

  2、修改repository的配置目录D:\apache-maven-3.1.1\conf\settings.xml

  a、找到该标签<localRepository>/path/to/local/repo</localRepository>

  修改为:<localRepository>D:/apache-maven-3.1.1/repo</localRepository>

  b、找到<servers>标签

  在其中加入:  

<server>
    <id>nexus-releases</id>
    <username>admin</username>
    <password>admin</password>
</server>
<server>
    <id>nexus-snapshots</id>
    <username>admin</username>
    <password>admin</password>
</server>
View Code

  c、找到<profiles>标签

  在其中加入:

  

<profile> 
  <id>spring</id>  
  <repositories>  
       <repository> 
           <id>springsourcerepo</id>  
           <name>SpringSource Repository</name>
           <url>http://repo.springsource.org/release</url>  
  </repository>  
  </repositories> 
</profile> 
<profile>  
    <id>dev</id>  
    <repositories>  
        <repository>
             <id>nexus</id>  
<url>http://172.16.10.59:8081/nexus/content/groups/public/</url>  
 <releases> 
  <enabled>true</enabled>  
  </releases> 
 <snapshots> 
  <enabled>true</enabled>    </snapshots>   </repository>   </repositories>  <pluginRepositories>  <pluginRepository>   <id>nexus</id>  
  <url>http://172.16.10.59:8081/nexus/content/groups/public</url>   <releases> 
  <enabled>true</enabled>    </releases>  <snapshots> 
  <enabled>true</enabled>    </snapshots> 
  </pluginRepository>   </pluginRepositories>   </profile> 

以上这段可参考:http://wenku.baidu.com/link?url=ZvbHFA2Rx_817I17t6_Ee7cEnb3415MH5ChpKNMPDwtZficpZvKUHVwECQdH7oVx_TXwvnhGuQS5HmGLh0voWb8J_O62eO_uf5tJ947msuC

  d、找到<profiles>标签

  <pluginGroups>中加入:<pluginGroup>org.mortbay.jetty</pluginGroup>  

五、生成自己的maven项目

  运行cmd.exe--->进入要建立项目的目录------->执行

  

mvn archetype:create -DgroupId=com.demo.app -DartifactId=demo-app
View Code

 

转载于:https://www.cnblogs.com/jianxie/p/3529069.html

阅读终点,创作起航,您可以撰写心得或摘录文章要点写篇博文。去创作
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Maven是一个强大的构建工具,用于管理Java项目的依赖和构建过程。在进行Maven配置之前,你需要确保已经安装了Maven,并将其加入到系统环境变量中。 以下是一些基本的Maven配置步骤: 1. 创建一个Maven项目:使用命令行或者集成开发环境(IDE)创建一个新的Maven项目。在项目根目录下会生成一个pom.xml文件,用于定义项目的配置信息。 2. 配置pom.xml:打开pom.xml文件,可以配置项目的依赖、插件、构建目标等。在 `<dependencies>` 标签内添加你所需的依赖项,例如: ```xml <dependencies> <dependency> <groupId>group-id</groupId> <artifactId>artifact-id</artifactId> <version>version</version> </dependency> </dependencies> ``` 3. 配置仓库:Maven默认从中央仓库下载依赖项,你也可以配置其他仓库。在pom.xml的 `<repositories>` 标签内添加仓库配置,例如: ```xml <repositories> <repository> <id>repo-id</id> <url>http://example.com/repo</url> </repository> </repositories> ``` 4. 执行Maven命令:使用命令行或者IDE提供的Maven插件执行Maven命令,例如构建项目、运行测试等。常用的命令包括: - `mvn clean`: 清理项目构建产生的文件。 - `mvn compile`: 编译项目。 - `mvn test`: 运行项目的测试。 - `mvn package`: 打包项目。 - `mvn install`: 将项目安装到本地仓库。 这些是基本的Maven配置步骤,你可以根据项目的具体需求进一步配置和使用Maven

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值