maven相关

1、配置阿里云镜像

<mirrors>
<!-- 配置具体的仓库的下载镜像-->
    <mirror>
        <!-- 镜像唯一标识符,用来区分不同的mirror元素 -->
        <id>nexus-aliyun</id>
        <!-- 对哪种仓库进行镜像,简单说就是替换哪个仓库-->
        <mirrorOf>central</mirrorOf>
        <!-- 镜像名称-->
        <name>Nexus aliyun</name>
        <!-- 镜像URL -->
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
  </mirror>
</mirrors>                

2、maven构建命令

mvn compile  #编译
mvn clean    #清理
mvn test     #测试
mvn package  #打包
mvn install  #安装到本地仓库

3、tomcat7运行插件

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.1</version>
      <configuration>
        <port>80</port>
        <path>/</path>
      </configuration>
      </plugin>
    </plugins>
</build>

4、可选依赖

#使用optional控制,指对外隐藏当前依赖的资源,不透明,将不会传递到其他项目
<
dependency>   <groupId>junit</groupId>   <artifactId>junit</artifactId>   <version>4.12</version>   <optional>true</optional> </dependency>

5、排除依赖

#使用exclusions控制,主动断开依赖的资源,被排除的资源无需指定版本
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.12</version>
  <exclusions>
    <exclusion>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
    </exclusion>
  </exclusions>
</dependency>

6、依赖范围

 

7、依赖范围传递性

 

posted @ 2022-04-19 10:04  记忆留一道伤疤  阅读(19)  评论(0编辑  收藏  举报