繁体   English   中英

Eclipse没有看到Maven依赖

[英]Eclipse doesn't see Maven dependency

我正在尝试将Maven依赖项从当前更改为另一个。 除了一些更改之外,这个其他依赖项几乎完全提供与当前依赖项相同的功能,因为当前的依赖项是另一个版本的旧版本的分支。 要做到这一点,我有:

  1. 将对pom中旧旧依赖项的所有引用更改为新依赖项
  2. 在Eclipse中删除并重新导入项目
  3. maven clean install

但是,我仍然遇到与开头时相同的问题:

  1. Eclipse没有看到任何依赖类。 它甚至不提供导入它们。
  2. 在项目上尝试mvn clean package时,Maven使用以下错误消息使构建失败:

    [ERROR] Failed to execute goal on project eet-demo-maven: Could not resolve dependencies for project cz.tomasdvorak:eet-demo-maven:jar:1.0-SNAPSHOT: Failed to collect dependencies at com.github.todvorak:eet-client:jar:1.3.2: Failed to read artifact descriptor for com.github.todvorak:eet-client:jar:1.3.2: Could not transfer artifact com.github.todvorak:eet-client:pom:1.3.2 from/to jitpack.io (https://jitpack.io): Not authorized , ReasonPhrase:Repo not found or no access token provided. -> [Help 1]

我已经检查过ppos的错别字和版本的正确性,所以那些应该不是问题。 我怀疑这与依赖关系/依赖关系管理/ jitpack以及它们如何工作有关。 我从来没有碰过他们; 那里的所有内容都要么是从我为项目开始的代码中复制出来的,要么是我随后与Maven摆弄的结果,其中我几乎完全是初学者。 我看了一下这个问题,并尝试了那里的解决方案,但没有一个在我的情况下工作。

如何让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>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.akathist.maven.plugins.launch4j</groupId>
                <artifactId>launch4j-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>l4j-clui</id>
                        <phase>package</phase>
                        <goals>
                            <goal>launch4j</goal>
                        </goals>
                        <configuration>
                            <dontWrapJar>true</dontWrapJar>
                            <headerType>console</headerType>
                            <jar>eet-demo-maven-1.0-SNAPSHOT.jar</jar>
                            <outfile>target\EETSender.exe</outfile>
                            <errTitle></errTitle>
                            <cmdLine></cmdLine>
                            <chdir>.</chdir>
                            <priority>normal</priority>
                            <downloadUrl>http://java.com/download</downloadUrl>
                            <supportUrl></supportUrl>
                            <stayAlive>true</stayAlive>
                            <restartOnCrash>true</restartOnCrash>
                            <manifest></manifest>
                            <icon></icon>
                            <singleInstance>
                                <mutexName>EETMutex</mutexName>
                                <windowTitle></windowTitle>
                            </singleInstance>
                            <classpath>
                                <mainClass>cz.tomasdvorak.eetdemo.Main</mainClass>
                            </classpath>
                            <jre>
                                <path></path>
                                <bundledJre64Bit>false</bundledJre64Bit>
                                <bundledJreAsFallback>false</bundledJreAsFallback>
                                <minVersion>1.6.0_1</minVersion>
                                <maxVersion></maxVersion>
                                <jdkPreference>preferJre</jdkPreference>
                                <runtimeBits>64/32</runtimeBits>
                            </jre>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <mainClass>cz.tomasdvorak.eetdemo.Main</mainClass>
            </manifest>
        </archive>
        <descriptors>
            <descriptor>assembly.xml</descriptor>
         </descriptors>
    </configuration>
</plugin>

</plugins>
    </build>

     <groupId>cz.tomasdvorak</groupId>
    <artifactId>eet-demo-maven</artifactId>
    <version>1.0-SNAPSHOT</version>

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.github.todvorak</groupId>
            <artifactId>eet-client</artifactId>
            </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.github.todvorak</groupId>
                <artifactId>eet-client</artifactId>
                <version>1.3.2</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

编辑: 有关GitHub的依赖项

编辑2:我改变了pom如下,我显然已经安抚了Maven的精神再次建立项目。 Eclipse让我导入之前看不到的所有东西。 然而,对这种突然改变的解释仍然是他的问题的一个有价值的结论。

<project>
.
.
.
    <dependencies>
    <dependency>
        <groupId>com.github.todvora</groupId>
        <artifactId>eet-client</artifactId>
        <version>1.3.2</version>
    </dependency>
    </dependencies>
<!-- 
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.github.todvorak</groupId>
                <artifactId>eet-client</artifactId>
                <version>1.3.2</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
     -->
</project>

依赖应该是:

<dependencies>
    <dependency>
        <groupId>com.github.todvora</groupId>
        <artifactId>eet-client</artifactId>

    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.github.todvora</groupId>
            <artifactId>eet-client</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>
</dependencyManagement>

你向tordova添加了额外的k

暂无
暂无

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

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