Maven:我不想在.m2目录中下载默认的junit jar

时间:2018-06-02 20:07:01

标签: java maven junit windows-10

我删除并清除 c:\ users \ myuser.m2 \ repository 目录下的所有文件和文件夹。

然后我用一个简单的 pom 运行mvn clean install命令:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.daniel</groupId>
    <artifactId>hola</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <properties>
        <java.version>1.8</java.version>
        <maven.compiler.version>3.7.0</maven.compiler.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

如何避免或排除 .m2 目录下 junit 文件夹及其文件的下载?

.m2 junit directory

1 个答案:

答案 0 :(得分:0)

如果您只想更改下载maven插件的默认目录,则可以使用必须放在<localRepository>标记内的<settings>标记

<settings>
    <localRepository>path/to/your/directory</localRepository>
<settings>

you can also take a look similar options on the maven documentation that could be of help.

(为了简单和可读性,我省略了设置标签属性)