Файл Pom / Jar находится не в центре - PullRequest
0 голосов
/ 30 января 2019

Я пытаюсь запустить независимый jar для моего Java-проекта, который прекрасно работает в IntelliJ.

Зависимость JRAW включена в мой файл pom, но во время работы mvn clean install Iполучаю следующую ошибку

[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]

Здесь упоминается, что файл jar присутствует в Spring Lib Release .

Как мнезаставить мой pom-файл выглядеть в библиотеке Spring вместо maven central.

Также я использую 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 голосов
/ 30 января 2019

Когда вы смотрите на Репозиторий Maven , появляется примечание:

Примечание: этот артефакт находится в 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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...