The error is due to maven not having been able to resolve the dependency on any of the repositories that are configured, either from the repositories that are standard, or from what you've specified in your settings (in the case of Primefaces ).
Instead of manually adding the dependency to your local repository (by default found in .m2
in the user directory) you can add a repository that has such a dependency, since there is an online and public repository that has it.
The sonatype repository (heavily used, inclusive) has the dependency you need. So to resolve dependency on it, just add something like this to your pom.xml
:
<repository>
<id>sonatype-releases</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
And after that you will be able to solve it, in the way you have declared or removed the compile
scope that is standard, and it can look like this:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.1.2</version>
</dependency>
The approach of saying that dependencies that by nature do not come up with scope provided
should be avoided ( see the meaning of each scope ), since there is a great chance of errors occurring.
Below is a complete example of pom.xml
using the configuration as stated:
<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>com.brunocesar</groupId>
<artifactId>jasper-dependency</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.1.2</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-releases</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
</repositories>
</project>
This is the dependency download log:
[INFO] ------------------------------------------------------------------------
[INFO] Building jasper-dependency 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://oss.sonatype.org/content/repositories/releases/net/sf/jasperreports/jasperreports/5.1.2/jasperreports-5.1.2.pom
Downloaded: https://oss.sonatype.org/content/repositories/releases/net/sf/jasperreports/jasperreports/5.1.2/jasperreports-5.1.2.pom (13 KB at 7.5 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/net/sf/jasperreports/jasperreports/5.1.2/jasperreports-5.1.2.jar
Downloaded: https://oss.sonatype.org/content/repositories/releases/net/sf/jasperreports/jasperreports/5.1.2/jasperreports-5.1.2.jar (4428 KB at 402.8 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jasper-dependency ---
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jasper-dependency ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.988 s
[INFO] Finished at: 2015-08-07T10:51:48-03:00
[INFO] Final Memory: 10M/183M
[INFO] ------------------------------------------------------------------------
As you can see the download was done from the quoted and configured repository. As in your case went wrong, some possible causes are:
- wrong configured repository;
- cache in the local maven repository, force update using
mvn clean compile -U
or some other lifecycle