Pom / Jar文件不在中央位置

时间:2019-01-30 10:14:08

标签: java maven

我正在尝试为我的Java项目运行一个独立的jar,该项目在IntelliJ中运行良好。

依存关系JRAW包含在我的pom文件中,但是在运行mvn clean install时出现以下错误

[ERROR] Failed to execute goal on project reddit-crawl-maven: Could not resolve dependencies for project com.test1:reddit-crawl-maven:jar:1.0-SNAPSHOT: Could not find artifact net.dean.jraw:JRAW:jar:1.1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

here提到Spring Lib Release中存在jar文件。

如何使pom文件在Maven Central的Spring库中显示。

我也正在运行mvn -U clean install来避免出现以下错误

ERROR] Failed to execute goal on project reddit-crawl-maven: Could not resolve dependencies for project com.test1:reddit-crawl-maven:jar:1.0-SNAPSHOT: Failure to find net.dean.jraw:JRAW:jar:1.1.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

替代方法:

  1. 如果我想制作一个独立的JAR(与平台无关),那么即使本地缓存的存储库也可以工作。

  2. 如果我可以直接从源代码下载JRAW.JAR并相应地编译maven。

这是我的pom文件,如果有帮助的话:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         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.test1</groupId>
    <artifactId>reddit-crawl-maven</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <kotlin.version>1.1.3</kotlin.version>
        <junit.version>4.12</junit.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-runtime</artifactId>
            <version>${kotlin.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.dean.jraw</groupId>
            <artifactId>JRAW</artifactId>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.moshi</groupId>
            <artifactId>moshi</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.12.1</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <!--<mainClass>com.test1.Main</mainClass>-->
                            <mainClass>event.handlers.InventoryEventHandler</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>com.test1.Main</addClasspath>
                        </manifest>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

1 个答案:

答案 0 :(得分:3)

当您查看Maven Repository时,有一条注释:

  

注意:此工件位于 Spring Lib Release 存储库中   (http://repo.spring.io/libs-release/

我认为您需要在pom.xml中声明此存储库,如下所示:

<repository>
    <id>spring-lib-release-repo</id>
    <name>Spring Lib Release Repository</name>
    <url>http://repo.spring.io/libs-release/</url>
</repository>