源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

详解Maven环境的搭建与idea配置

  • 时间:2022-06-22 05:52 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:详解Maven环境的搭建与idea配置
本文主要介绍了Maven环境的搭建与idea配置,分享给大家,具体如下: Maven 下载: [url=http://maven.apache.org/download.cgi]http://maven.apache.org/download.cgi[/url] Maven 中央仓库地址:[url=http://search.maven.org]http://search.maven.org[/url] [b]配置maven环境变量[/b] M2_HOME:D:\workspace\maven\apache-maven-3.0.5 Path:;%M2_HOME%/bin; 检查是否成功,打开CMD: Mvn -v mvn install 会将项目生成的构件安装到本地Maven仓库 mvn deploy 用来将项目生成的构件分发到远程Maven仓库 D:\>mvn archetype:generate:在D:盘构建maven标准项目目录结构 2、settings.xml文件配置 2.0修改本地仓库位置 M2_home目录下 conf/settings.xml
<localRepository>D:/workspace/maven/stone</localRepository> 
2.1如何配置远程仓库(私服): (nexus-2.0.4-1-bundle)
<profiles> 
  <profile> 
    <id>nexus</id> 
    <repositories><!--配置远程仓库--> 
      <repository> 
        <id>nexus</id> 
        <name>Central Repository</name> 
        <url>http://127.0.0.1/nexus/content/groups/public</url> 
        <releases> 
          <enabled>true</enabled> 
        </releases> 
        <snapshots> 
          <enabled>false</enabled><!----> 
        </snapshots> 
      </repository> 
    </repositories> 
    <pluginRepositories><!--配置Maven从什么地方下载插件构件--> 
      <pluginRepository> 
        <id>nexus</id> 
        <name>Central Repository</name> 
        <url>http://127.0.0.1/nexus/content/groups/public</url> 
        <releases> 
          <enabled>true</enabled> 
        </releases> 
        <snapshots> 
          <enabled>false</enabled> 
        </snapshots> 
      </pluginRepository> 
    </pluginRepositories> 
  </profile> 
</profiles> 
 
<activeProfiles><!--激活 远程仓库--> 
    <activeProfile>nexus</activeProfile> 
</activeProfiles> 
2.2还可以配置仓库的镜像下载
<mirrors> 
<mirror><!--配置镜像--> 
  <id>nexus</id> 
  <mirrorOf>*</mirrorOf> 
  <url>http://127.0.0.1/nexus/content/groups/public</url> 
</mirror> 
</mirrors> 
3、pom.xml文件配置依赖
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
  <modelVersion>4.0.0</modelVersion> 
  <groupId>xu.feifei</groupId> 
  <artifactId>feifei</artifactId> 
  <packaging>war</packaging> 
  <version>1.0</version> 
 
  <dependencies> 
 
    <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
    </dependency> 
    <dependency> 
      <groupId>org.json</groupId> 
      <artifactId>json</artifactId> 
      <version>20090211</version> 
    </dependency> 
 
  </dependencies> 
 
  <build> 
    <finalName>feifei</finalName> 
  </build> 
   
</project> 
二、IDEA的搭建Maven相关配置 [img]http://files.jb51.net/file_images/article/201712/2017120110051151.png[/img] . [img]http://files.jb51.net/file_images/article/201712/2017120110051152.png[/img] maven项目的包结构 [img]http://files.jb51.net/file_images/article/201712/2017120110051153.png[/img] 设置maven自动导包 [img]http://files.jb51.net/file_images/article/201712/2017120110051254.png[/img] [img]http://files.jb51.net/file_images/article/201712/2017120110051255.png[/img] [img]http://files.jb51.net/file_images/article/201712/2017120110051256.png[/img] 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部