我尝试在我的项目中使用com.github.maheshbabu11.ntfy.java,但Maven找不到它:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile): Compilation failure: Package ntfyJava is not available.
但是,当我下载 Java 源文件时,我的代码已编译并执行得很好。
我的进口声明:
import ntfyJava.NtfyClient;
import ntfyJava.core.model.*;
import ntfyJava.core.publish.PubClient;
我的
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>page.codeberg.pixelcode.group</groupId>
<artifactId>page.codeberg.pixelcode.artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0-rc1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>com.github.maheshbabu11</groupId>
<artifactId>ntfy.java</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/MaheshBabu11/ntfy-java</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
我根据
GitHub的Maven文档配置了我的
~/.m2/settings.xml
:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/MaheshBabu11/ntfy-java</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>realpixelcode</username>
<password>github_pat_CMU...OJ8</password>
</server>
</servers>
</settings>
我的
module-info.java
:
module page.codeberg.pixelcode.Group {
requires ntfy.java;
}
如何从 GitHub 正确导入
ntfyJava
?
谢谢!
在上游存储库中修复:
这个问题是我的错,文件夹结构必须是
才能正确构建包。已经解决了这个问题,您应该能够下载 jar 并让它工作。src/main/java/<package-name>
– 马赫什·巴布
https://github.com/MaheshBabu11/ntfy-java/issues/7#issuecomment-2147481368