Maven没有加载对本地工件的依赖

时间:2019-06-18 16:59:31

标签: java maven dependencies

我创建了自己的jar文件,并希望将其作为依赖项连接到另一个项目。 jar内有自己的带有依赖项的pom文件。 在将jar与系统范围连接时,我遇到了一个问题-maven不会加载依赖项jar。

也许我在构建jar时忘记了一些插件?

如何从本地jar获取Maven加载依赖项?

POM我的Jar文件

<groupId>ru.qa.eso</groupId>
<artifactId>push-qa</artifactId>
<version>0.1.0-alfa</version>
<packaging>jar</packaging>
<name>PushQA</name>

<properties>
    <selenide.version>5.2.3</selenide.version>
    <rest-assured.version>3.3.0</rest-assured.version>
    <cucumber.version>4.2.0</cucumber.version>
    <lombok.version>1.18.4</lombok.version>
    <logback.version>1.3.0-alpha4</logback.version>
    <jul-to-slf4j.version>1.7.25</jul-to-slf4j.version>
    <allure.version>2.9.0</allure.version>
    <maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
    <aspectjweaver.version>1.9.2</aspectjweaver.version>
    <allure-maven.version>2.10.0</allure-maven.version>
    <reflections.version>0.9.11</reflections.version>
    <maven.compiler.targer>1.8</maven.compiler.targer>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>

<dependencies>
    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>selenide</artifactId>
        <version>${selenide.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java8</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>${rest-assured.version}</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jul-to-slf4j</artifactId>
        <version>${jul-to-slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-rest-assured</artifactId>
        <version>2.10.0</version>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-junit4</artifactId>
        <version>${allure.version}</version>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-cucumber4-jvm</artifactId>
        <version>${allure.version}</version>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-selenide</artifactId>
        <version>${allure.version}</version>
    </dependency>
    <dependency>
        <groupId>org.reflections</groupId>
        <artifactId>reflections</artifactId>
        <version>${reflections.version}</version>
    </dependency>
    <dependency>
        <groupId>com.github.mifmif</groupId>
        <artifactId>generex</artifactId>
        <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>27.1-jre</version>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>json-schema-validator</artifactId>
        <version>3.3.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <target>${maven.compiler.targer}</target>
                <source>${maven.compiler.source}</source>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
                <execution>
                    <id>attach-resource-bundle</id>
                    <goals>
                        <goal>resource-bundle</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <encoding>UTF-8</encoding>
                <additionalOptions>-Xdoclint:none</additionalOptions>
                <additionalJOption>-Xdoclint:none</additionalJOption>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <argline>-Dfile.encoding=UTF-8</argline>
            <loggerLevel>INFO</loggerLevel>
            <startOnServer>false</startOnServer>
        </properties>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>server</id>
        <properties>
            <argline>-Dfile.encoding=UTF-8</argline>
            <loggerLevel>DEBUG</loggerLevel>
            <startOnServer>true</startOnServer>
        </properties>
    </profile>
</profiles>

POM我的项目,我想在其中加入我的罐子

<groupId>ru.qa.eso</groupId>
<artifactId>SomeName</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>ru.qa.eso</groupId>
        <artifactId>push-qa</artifactId>
        <version>0.1.0-alfa</version>
    </dependency>
</dependencies>

2 个答案:

答案 0 :(得分:-1)

请使用“ mvn install”或“ mvn clean install”构建依赖项jar。然后将该依赖项添加到依赖项目中并进行构建。希望它将解决您的问题

答案 1 :(得分:-1)

您可以尝试通过将范围作为依赖项的编译范围进行尝试吗?

 <dependency>
        <groupId>ru.qa.eso</groupId>
        <artifactId>push-qa</artifactId>
        <version>0.1.0-alfa</version>
        <scope>compile</scope>
    </dependency>

请通过以下链接获取有关范围的更多详细信息。 Scope of Dependency

希望这会有所帮助。