简体   繁体   English

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

[英]Maven not loading dependency on local artifact

I have created my own jar file and want to connect it to another project as a dependency. 我创建了自己的jar文件,并希望将其作为依赖项连接到另一个项目。 Inside the jar has its own pom file with dependencies. jar内有自己的带有依赖项的pom文件。 When connecting jar with system scope, I have a problem - maven does not load the dependencies jar. 当将jar与系统范围连接时,我遇到了一个问题-maven不会加载依赖项jar。

Maybe i forgot some plugin when building jar? 也许我在构建jar时忘记了一些插件?

How can I make maven load dependencies from a local jar? 如何从本地jar使Maven加载依赖项?

POM my Jar file 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 my project, where i want include my jar 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>

Please use "mvn install" or "mvn clean install" for building the dependency jar. 请使用“ mvn install”或“ mvn clean install”来构建依赖项jar。 Then add that dependency in dependent project and build.Hopefully it will resolve your issue 然后将该依赖项添加到依赖项目并进行构建,希望它将解决您的问题

Can you try by including the scope as compile for dependency as below: 您可以尝试通过将范围作为依赖项的编译范围进行尝试吗,如下所示:

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

Kindly go through following link to get more details regarding scope. 请通过以下链接获取有关范围的更多详细信息。 Scope of Dependency 依赖范围

Hope this was helpful. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM