IntelliJ IDEA使用教程(动图详解):IntelliJ IDEA 配合 Maven 的一些技巧

IntelliJ IDEA 配合 Maven 的一些技巧

环境

  • IntelliJ IDEA 2017.1
  • Maven 3.3.9
  • Nexus 3.2.1

学习前提

  • 了解 Maven 配置的基本用法
  • 了解私有仓库,比如 nexus 的一些概念
  • 强烈建议把 Maven 的 settings.xml 文件同时放在:%USER_HOME%/.m2/settings.xml${maven.home}/conf/settings.xml 两个地方。避免使用终端的时候默认去调用用户目录下的

Maven 中的 profile

  • Maven 中有一个概念叫做:profile,它的诞生主要是为了解决不同环境所需的不同变量、配置等问题。
  • 有了 profile,可以根据激活的条件,启动不同条件下的配置信息。
  • profile 是可以有多个的,也可以同时激活多个 profile,方便自由组合。
  • profile 一般可以在三个地方:settings.xml,pom.xml,profiles.xml(这个不常用)
  • 在 settings.xml 上,一般大家用来做仓库的选择,比如以下 settings.xml 代码:
<?xml version="1.0" encoding="UTF-8"?>

<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>D:\maven\my_local_repository</localRepository>

    <pluginGroups>
    </pluginGroups>

    <proxies>
    </proxies>

    <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>nexus</id>
                    <url>http://192.168.1.73:8081/repository/maven-public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <url>http://192.168.1.73:8081/repository/maven-public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
        <profile>
            <id>aliyun</id>
            <repositories>
                <repository>
                    <id>aliyun</id>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    <releases>
                        
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值