Maven failed to download dependencies after adding dependency to pom.xml - java

What is the correct way to add dependency in Intelli?
I have added
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
to pom.xml but I got the error
Failed to execute goal on project accessing-data-mysql: Could not resolve dependencies for project com.e
xample:accessing-data-mysql:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.springframework.boot:sprin
g-boot-configuration-processor:jar:2.4.7: Failed to read artifact descriptor for org.springframework.boot:spring
-boot-configuration-processor:jar:2.4.7: Could not transfer artifact org.springframework.boot:spring-boot-config
uration-processor:pom:2.4.7 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://
repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-configuration-processor/2.4.7/spring-boot-conf
iguration-processor-2.4.7.pom: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParam
eterException: the trustAnchors parameter must be non-empty -> [Help 1]
when I do mvn install. I have try maven->reload project and it still didn't work. Any idea on how to solve the problem?

After a failed attempt, maven will leave a small file in your local .m2 repository that will prevent any attempt to re-download the file unless the update interval has elapsed or you force the updates using the maven -U switch described in other answers.
Just delete the folder for that artifact in your local m2 repository and update you project; a new download attempt will trigger.
rm -rf ~/.m2

Related

Maven Unable to Collect Dependencies at Extra Repositories

I working on converting a project from ant to maven and am getting errors trying to pull in jars from geomajas.
I am not behind a firewall and the dependencies from maven central are downloading. I have also added geomajas to the repositories in my projects pom.xml.
Below are the relevant portions from the pom.xml and the error I am getting.
If I instead define the jar dependency with a system path to a local copy of the jar the project builds successfully.
<dependency>
<groupId>org.lobobrowser</groupId>
<artifactId>cobra</artifactId>
<version>0.98.4</version>
</dependency>
.....
<repository>
<id>geomajas</id>
<name>Geomajas Maven Repository</name>
<url>https://maven.geomajas.org/(https://maven.geomajas.org/)</url>
</repository>
[ERROR] Failed to execute goal on project niksun-services-util: Could not resolve dependencies for project com.niksun:niksun-services-util:jar:main: Failed to collect dependencies at org.lobobrowser:cobra:jar:0.98.4: Failed to read artifact descriptor for org.lobobrowser:cobra:jar:0.98.4: Could not transfer artifact org.lobobrowser:cobra:pom:0.98.4 from/to geomajas (http://maven.geomajas.org/(http://maven.geomajas.org/)): connect timed out -> [Help 1]

Maven dependency version

When doing a mvn clean install -U I am getting:
[ERROR] Failed to execute goal on project xxx-security: Could not resolve dependencies for project xxx:xxx-security:jar:50-SNAPSHOT: Failed to collect dependencies at
xxx:xxx-persistence:jar:50-SNAPSHOT -> org.mybatis:mybatis:jar:${mybatis.version}: Failed to read artifact descriptor for org.mybatis:mybatis:jar:${mybatis.version}: Could not
transfer artifact org.mybatis:mybatis:pom:${mybatis.version} from/to nexus (http://example.net/repository/Standard/): Failed to transfer file: http://example.net/repository/Stan
dard/org/mybatis/mybatis/$%7Bmybatis.version%7D/mybatis-$%7Bmybatis.version%7D.pom. Return code is: 400 , ReasonPhrase:Invalid repository path. -> [Help 1]
What I don't get is why maven is using mybatis.version in the url to get the dependency rather than a version number. I have searched the code and cannot find mybatis.version in there. I did find:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.0.4</version>
</dependency>
So why is maven using mybatis.version rather than 3.0.4?
It looks like your xxx:xxx-persistence:jar:50-SNAPSHOT jar has internal dependency with org.mybatis:mybatis:jar:${mybatis.version}. Provided that you define mybatis.version in your properties.
You can do following:
Execute mvn dependency:tree to check which specific jar has this dependency.
Also define <mybatis.version>3.0.4</mybatis.version> under <properties> section of pom.xml. You can optionally remove <version>3.0.4</version> from your <dependency> section where you defined mybatis dependency.

How can I download Infrequently used dependencies in maven?

Version: maven 3.6.3
I try to put this dependency into pom.xml,but it not auto download
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.11</artifactId>
<version>2.4.3</version>
</dependency>
so i use command line:
mvn dependency:get -DremoteRepositories=http://repo1.maven.org/maven2 -DgroupId=com.datastax.spark -DartifactId=spark-cassandra-connector_2.11 -Dversion=2.4.3 -Dtransitive=false
but it give me couldn't download artifact error log :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: Couldn't download artifact: Could not transfer artifact com.datastax.spark:spark-cassandra-connector_2.11:jar:2.4.3
Do I need to upgrade remoteRepositories?
Why are some commonly used packages automatically downloaded quickly ? such as guava,commons-lang.
Some new versions are always problematic to rely on for download,Is it no cache in
repository?
How can I download the dependency? Thanks

Error while using JCS : Failed to retrieve javax.sql:jdbc-stdext-2.0

While downloading JCS using Maven
<dependency>
<groupId>jcs</groupId>
<artifactId>jcs</artifactId>
<version>1.3</version>
</dependency>
Error :
[WARNING] An error occurred during dependency resolution.
Failed to retrieve javax.sql:jdbc-stdext-2.0
Caused by: Failure to find javax.sql:jdbc-stdext:jar:2.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the upd
ate interval of central has elapsed or updates are forced
Try downloading the file manually from:
http://java.sun.com/products/jdbc/download.html
Then, install it using the command:
mvn install:install-file -DgroupId=javax.sql -DartifactId=jdbc-stdext -Dversion=2.0 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=javax.sql -DartifactId=jdbc-stdext -Dversion=2.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) com.samsung.jcs:jcs_demo:jar:1.0-SNAPSHOT
2) jcs:jcs:jar:1.3
3) mysql:mysql-connector-java:jar:3.0.10
4) javax.sql:jdbc-stdext:jar:2.0
javax.sql:jdbc-stdext:jar:2.0
from the specified remote repositories:
central (http://repo.maven.apache.org/maven2, releases=true, snapshots=false)
[INFO] Unable to read jar manifest from C:\Users\arun.km\.m2\repository\javax\sql\jdbc-stdext\2.0\jdbc-stdext-2.0.jar
similarly
Failed to retrieve javax.transaction:jta-1.0.1B
Solution Use the new Grounp : org.apache.jcs
<dependency>
<groupId>org.apache.jcs</groupId>
<artifactId>jcs</artifactId>
<version>1.3</version>
</dependency>

Hudson Maven ${basedir} can't find dependency

I have a created a maven repo in a directory called lib in the base of my project.
I can use maven to build this project and fetch dependencies from the repo in the lib directory. When I try to build this project with Hudson, Hudson can not find the dependencies in the lib repo.
Here are the relevant parts of the project pom:
<dependency>
<groupId>manitou</groupId>
<artifactId>manitou.cxf.jar</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>ErpClientsLibRepo</id>
<url>file://${basedir}/lib</url>
</repository>
</repositories>
Here are the errors from Maven when ran from Hudson:
[INFO] o.h.m.e.h.MavenExecutionResultHandler - Build failed with exception(s)
[INFO] o.h.m.e.h.MavenExecutionResultHandler - [1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project DigabitERPClients: Could not resolve dependencies for project com.digabit:DigabitERPClients:jar:1.2.0: Failure to find manitou:manitou.cxf.jar:jar:1.0.0 in file:///opt/eng/hudson/jobs/20-DigabitJParent/workspace/DigabitErpClients/lib was cached in the local repository, resolution will not be reattempted until the update interval of ErpClientsLibRepo has elapsed or updates are forced
[DEBUG] Closing connection to remote
[ERROR] Failed to execute goal on project DigabitERPClients: Could not resolve dependencies for project com.digabit:DigabitERPClients:jar:1.2.0: Failure to find manitou:manitou.cxf.jar:jar:1.0.0 in file:///opt/eng/hudson/jobs/20-DigabitJParent/workspace/DigabitErpClients/lib was cached in the local repository, resolution will not be reattempted until the update interval of ErpClientsLibRepo has elapsed or updates are forced -> [Help 1]
Here is a dir listing at the path Maven (As ran by Hudson) seems to be looking at:
[root#vail lib]# cd /opt/eng/hudson/jobs/20-DigabitJParent/workspace/DigabitErpClients/lib
[root#vail lib]# ls
manitou
[root#vail lib]# ls manitou/
manitou.cxf.jar
[root#vail lib]#
Any ideas what I'm doing wrong? Thanks
I went into the hudson project and forced maven to update, now the build works :S

Categories