Java 如何使用Github操作将工件(Maven)部署到Github包
我正在尝试使用Maven作为构建工具,为一个简单的Spring启动应用程序编写github操作管道。构建和验证成功,但将Jar部署到Github注册表失败,错误为:Java 如何使用Github操作将工件(Maven)部署到Github包,java,maven,github-actions,Java,Maven,Github Actions,我正在尝试使用Maven作为构建工具,为一个简单的Spring启动应用程序编写github操作管道。构建和验证成功,但将Jar部署到Github注册表失败,错误为: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project space-management-system: Failed to deploy artifact
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project space-management-system: Failed to deploy artifacts/metadata: Cannot access registry=https://maven.pkg.github.com/Pranav3105/osmosis with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access registry=https://maven.pkg.github.com/Pranav3105/osmosis using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException
[ERROR] role: org.apache.maven.wagon.Wagon
[ERROR] roleHint: registry=https
这是我的pom.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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
</parent>
<groupId>com.mindtree</groupId>
<artifactId>space-management-system</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>space-management-system</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
<dependencies>
.........
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
<profiles>
<profile>
<id>sonar</id>
<properties>
...sonar properties.....
</properties>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<distributionManagement>
<repository>
<id>github</id>
<name>pranav3105</name>
<url>registry=https://maven.pkg.github.com/Pranav3105/osmosis</url>
</repository>
</distributionManagement>
</project>
我还尝试将servers标记放入settings.xml中,在maven部署阶段将其作为参数传递,但也失败了,出现了相同的错误。我认为您应该从pom.xml中的distributionManagement>repository>url的开头删除“registry=”
<distributionManagement>
<repository>
<id>github</id>
<name>pranav3105</name>
<url>https://maven.pkg.github.com/Pranav3105/osmosis</url>
</repository>
</distributionManagement>
github
普拉纳夫3105
https://maven.pkg.github.com/Pranav3105/osmosis
看,这是一个很好的样本
<distributionManagement>
<repository>
<id>github</id>
<name>pranav3105</name>
<url>https://maven.pkg.github.com/Pranav3105/osmosis</url>
</repository>
</distributionManagement>