英文:
Maven plugin cannot be resolved
问题
我搜索了这个问题,如标题所示,但仍然不知道我应该做什么。我正在尝试构建一个可执行的JAR文件,但其中一个插件maven-assembly-plugin
无法解析。
我尝试了https://maven.apache.org/plugins/maven-assembly-plugin/usage.html,但它不起作用。我将整个pom.xml
文件都放在了底部。非常感谢任何帮助。
以下是错误消息:
插件无法解析。确保插件的groupId、artifactId和version都存在。附加信息:插件org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5或其依赖项之一无法解析:无法读取org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5的构件描述符
以下是文件:
<?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>distributed.systems</groupId>
<artifactId>leader.election</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>leader.election</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.6.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>14</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>LeaderElection</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
注意:以上是您提供的XML代码的翻译。
英文:
I've searched this problem as the title says but still don't know what I should do. I am trying to build an executable jar file, but one of the plugins maven-assembly-plugin
cannot be resolved.
I've tried the https://maven.apache.org/plugins/maven-assembly-plugin/usage.html
but it doesn't work. I put the entire pom.xml
file, and the plugin is at the bottom of the file. Any help is highly appreciated.
Here is the error message:
Plugin could not be resolved. Ensure the plugin's groupId, artifactId and
version are present. Additional information: Plugin
org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its
dependencies could not be resolved: Failed to read
artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5
Here is the file:
<?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>distributed.systems</groupId>
<artifactId>leader.election</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>leader.election</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.6.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>14</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>LeaderElection</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
答案1
得分: 5
您可能正在使用一个旧版本的Maven,该版本尝试通过HTTP协议获取插件。这已经在几个月前被禁用了。您必须要么使用更新版本的Maven,要么更改您的本地配置文件~/.m2/settings.xml
(或C:\users\you\.m2\settings.xml
)以使用HTTPS。如果没有这样的文件,您可以通过复制以下示例来创建它:
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<profiles>
<profile>
<id>stefan</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>https://repo.springsource.org/libs-milestone/</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jboss</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
英文:
You are possibly using an old Maven version that tries to fetch plugins via HTTP protocol. That has been disabled a few month ago. You must either use a more recent version of Maven or change your local configuration file ~/.m2/settings.xml
(or C:\users\you\.m2\settings.xml
) to use HTTPS. If there is no such file, you can create it by copying from the example:
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<profiles>
<profile>
<id>stefan</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>https://repo.springsource.org/libs-milestone/</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jboss</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
答案2
得分: 3
你必须将groupId放在artifactId之上。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>de.uulm.sp.pvs.sokoban.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
英文:
You have to put the groupId in above the artifactId.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>de.uulm.sp.pvs.sokoban.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
答案3
得分: 0
对于这个问题,我决定使用下载的Apache Maven压缩包而不是Eclipse内置的Maven。
-
检查Eclipse内是否已安装Maven。
文件 → 新建 → 其他 -
安装
m2e
插件。
帮助 → 安装新软件 http://download.eclipse.org/technology/m2e/releases -
下载Maven压缩包并设置环境变量到主文件夹。
-
如果成功,在命令提示符中执行
mvn --version
命令将会看到Maven的版本和相关信息。 -
在已下载的Maven文件夹中,创建一个新文件夹
repository
。 -
在已下载的Maven文件夹中,找到
conf/
→settings.xml
。查找标签<localRepository>
并修改路径为刚刚创建的repository
文件夹。 -
Windows → 首选项 → Maven → 安装 → 添加 → 选择已下载的Maven文件夹 → 应用
-
Maven → 用户设置 → 浏览编辑过的
settings.xml
→ 确定 -
重启Eclipse。
如果所有步骤都成功完成,插件问题将会解决。
参考链接:https://o7planning.org/en/10101/install-maven-into-eclipse
英文:
For this question, I decided to use the downloaded apache maven zip instead of the built-in maven in eclipse.
- Check if Maven inside eclipse.
File → New → Other - Install
m2e
.
Help → Install New Software http://download.eclipse.org/technology/m2e/releases - Download the Maven zip and set the environment variables to the main folder.
- If successful, in cmd,
mvn --version
command shall see the version of maven and related information. - In the downloaded maven folder, create a new folder
repository
. - In the downloaded maven folder, find
conf/
→settings.xml
. Find the tag<localRepository>
and modify the path to therepository
folder just created. - Windows → Preferences → Maven → Installations → Add → Directory to the downloaded maven folder → Apply
- Maven → User Settings → Browse the edited
settings.xml
→ OK - Restart eclipse.
If all processes are successful, then the plugin issue will be resolved.
reference: https://o7planning.org/en/10101/install-maven-into-eclipse
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论