我成功地将 maven 包部署到 jcenter,但是当我在另一个项目上使用此包时,它给了我一个错误



作为标题,我成功地将包部署到jcenter,这是我的pom.xml。

<?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>io.github.bloodnighttw.JDAwP</groupId>
<artifactId>JDAwP</artifactId>
<version>1.0.0_6</version>
<packaging>jar</packaging>
<name>JDAwP</name>
<distributionManagement>
<repository>
<id>bintray-bloodnighttw-JDAwP</id>
<name>bloodnighttw-JDAwP</name>
<url>https://api.bintray.com/maven/bloodnighttw/JDAwP/JDAwP/;publish=1</url>
</repository>
</distributionManagement>

<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.1.1_104</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>    
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName></shadedClassifierName> <!-- Any name that makes sense -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

所以我运行mvn deploy,它部署成功。(这是我的源代码(

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:00 min
[INFO] Finished at: 2020-02-11T18:56:26+08:00
[INFO] ------------------------------------------------------------------------

我想在另一个项目中使用此包。 所以我在另一个项目的pom中添加了一些东西.xml。 这是我"另一个项目"的绒球.xml

<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>io.github.bloodnighttw</groupId>
<artifactId>Another-Projects</artifactId>
<version>0.0-SNAPSHOT</version>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.github.bloodnighttw.JDAwP</groupId>
<artifactId>JDAwP</artifactId>
<version>1.0.0_5</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

我的项目中只有一个类(位于/src/main/java/中( 它是"Main.java",这个文件的代码是:

import io.github.*;
public class Main{
//nothing here
}

我跑mvn install,我得到了这个错误!

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.212 s
[INFO] Finished at: 2020-02-11T18:49:06+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Another-Projects: Compilation failure
[ERROR] /home/bbeenn1227/桌面/testMaven/src/main/java/Main.java:[1,1] package io.github does not exist

(顺便说一下,我很确定我有包"io.github.*"(

本周我一直在谷歌上搜索解决方案,但我找不到任何如何解决的答案。 所以我决定在stackoverflow上发布一个问题。 如果你认为我的问题很愚蠢,请给我一些关于如何处理它的信息。

(对不起我的英语不好(

依赖关系可能应该是

<dependency>
<groupId>io.github.bloodnighttw.JDAwP</groupId>
<artifactId>JDAwP</artifactId>
<version>1.0.0_5</version>
</dependency>

而不是

<dependency>
<groupId>io.github.bloodnighttw.JDAwP</groupId>
<artifactId>JDAwP</artifactId>
<version>1.0.0_5</version>
<type>pom</type>
</dependency>

相关内容

最新更新