Issue
I'm trying to create a runnable jar file, but somehow my Maven/Netbeans fails to do so. This is my 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>de.ksw</groupId>
<artifactId>KBSE-CDI-Testprogram</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<version>1.8.1</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>de.ksw.kbse.cdi.testprogram.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>KBSE-CDI</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
As you can see I already tried to add the main class. I also added the dependency maven-jar-plugins, but I still get an error messagen when I try to compile the project:
Plugin org.apache.maven.plugins:maven-jar-plugin:1.8.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar:1.8.1: Failure to find org.apache.maven.plugins:maven-jar-plugin:pom:1.8.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
What am I doing wrong here? How to fix this?
Solution
There is no version 1.8.1
of maven-jar-plugin
.
Here the list of all available versions of maven-jar-plugin
: https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin
You have to update version
into an earlier version.
Example with the latest version :
<version>3.0.2</version>
Answered By - Mickael
Answer Checked By - Timothy Miller (JavaFixing Admin)