Unable to resolve dependencies in IntelliJ IDEA 2018.1 - java

I have a Java project with Maven dependency management. I copied it to another workstation and imported to IntelliJ IDEA. Dependencies from pom.xml file are not resolved. Maven Integration plugin is enabled, but Maven's Reimport function has no effect.
settings.xml file in .m2 folder:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
</settings>
Import Maven projects automatically option is set to on. I use JDK version 1.8.0_171 and Maven 3.5.4, which I set path manually in IDE.
IDE information:
IntelliJ IDEA 2018.1.5 (Community Edition)
Build #IC-181.5281.24, built on June 12, 2018
JRE: 1.8.0_152-release-1136-b39 x86
JVM: OpenJDK Server VM by JetBrains s.r.o
Windows 10 10.0

I copied repository folder under .m2 folder from my computer to second workstation and after that Maven dependencies are resolved.

Related

Errors when opening project(s) on import (maven dep

I just started with cloudstack and wanted to get the dev environment going. I have Maven installed, and using Eclipse. I've been following this guide, Which seems a bit outdated, but I've been unable to find anything more recent about getting this going in Eclipse.
Versions I'm running:
--Eclipse 4.1
--Maven 3.6.1
--Java 1.8.0_211
--Cloudstack 4.9
Upon importing I'm getting 152 errors (all seem related to maven):
*Description Resource Path Location Type
Missing artifact com.cloud.com.f5:icontrol:jar:1.0 pom.xml /cloud-plugin-network-f5 line 30 Maven Dependency Problem
*Description Resource Path Location Type Missing artifact com.cloud.com.netapp:manageontap:jar:4.0 pom.xml /cloud-plugin-netapp line
30 Maven Dependency Problem
*Description Resource Path Location Type Missing artifact com.cloud.com.vmware:vmware-vim25:jar:6.0 pom.xml /cloud-engine-storage-integration-test line
12 Maven Dependency Problem
*Description Resource Path Location Type Plugin execution not covered by lifecycle configuration:
org.apache.maven.plugins:maven-plugin-plugin:3.1:descriptor
(execution: default-descriptor, phase:
process-classes) pom.xml /Wix-cloudstack-maven-plugin line 16 Maven
Project Build Lifecycle Mapping Problem
*Description Resource Path Location Type The container 'Maven Dependencies' references non existing library
'C:\Users.m2\repository\com\cloud\com\f5\icontrol\1.0\icontrol-1.0.jar' cloud-plugin-network-f5 Build
path Build Path Problem
*Description Resource Path Location Type The import com.cloud.network.schema cannot be
resolved BrocadeVcsApi.java /cloud-plugin-network-vcs/src/com/cloud/network/brocade line
61 Java Problem
Probably a bit late, but may help other people trying this out for the first time.
Adding the Apache Maven repositories should allow you to build, for example I have added Maven Central and Apache Maven repositories with CloudStack 4.13.
This can be done by editing ~/.m2/settings.xml to include mirrors, it is important to use HTTPS not HTTP as this is deprecated and will result in failures by default.
Apache Repository Entry
Entry to be added to configuration.
<mirror>
<id>Apache HTTPS</id>
<mirrorOf>apache</mirrorOf>
<name>Apache (HTTPS)</name>
<url>https://repo.maven.apache.org/maven2/</url>
</mirror>
Example
Mirrors only entry for user.
<settings>
<mirrors>
<mirror>
<id>Central HTTPS</id>
<mirrorOf>central</mirrorOf>
<name>Maven Central (HTTPS)</name>
<url>https://repo1.maven.org/maven2/</url>
</mirror>
<mirror>
<id>Apache HTTPS</id>
<mirrorOf>apache</mirrorOf>
<name>Apache (HTTPS)</name>
<url>https://repo.maven.apache.org/maven2/</url>
</mirror>
</mirrors>
</settings>

Could not find artifact com.sun:tools:jar:0

I'm trying to use checkstyle and findbugs by doing mvn checkstyle:checkstyle but I have this error
This error
[ERROR] Failed to execute goal on project my-project: Could not resolve dependencies for project default:my-project:jar:1.1: Could not find artifact com.sun:tools:jar:0 at specified path C:\Program Files\Java\jdk-11.0.2/../lib/tools.jar -> [Help 1]
I do not have a tools.jar into my JDK (i have jdk-11.0.2).
I'm on it since 2H, please help :/
tools.jar removed from Java 9+
You're on JDK 11. No tools.jar found there.
JEP 220: Modular Run-Time Images removed both tools.jar and rt.jar from the lib folder, as of Java 9.
Removed: rt.jar and tools.jar
The class and resource files previously stored in lib/rt.jar,
lib/tools.jar, lib/dt.jar, and various other internal JAR files are
now stored in a more efficient format in implementation-specific files
in the lib directory. The format of these files is not specified and
is subject to change without notice.
This change is part of adding the Java Platform Module System, a.k.a. Project Jigsaw.
To upgrade Checkstyle, use later versions, such as:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.18</version>
</dependency>
</dependencies>
</plugin>
Notice the inner dependency block.
Consult a Maven repo for versions of Apache Maven Checkstyle Plugin and of Checkstyle.

Failed to execute goal errors when running mvn install:install-file [duplicate]

I am new to Maven and trying to setup my first project in Maven but receiving the below error message when I am doing " Run as -> Maven install " in Eclipse. Below is my settings.xml and pom.xml
Settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:\Users\Iam\.m2\repository</localRepository>
<profiles>
<profile>
<repositories>
<repository>
<id>central</id>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
</pluginRepositories>
</profile>
</profiles>
</settings>
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>com.mytest</groupId>
<artifactId>MySpringBootMaven</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.11.RELEASE</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version><!--$NO-MVN-MAN-VER$-->
<configuration>
<warnName>Test.war</warnName>
</configuration>
</plugin>
</plugins>
</build>
</project>
Error message:
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.springframework.boot:spring-boot-maven-plugin:jar:1.5.11.RELEASE
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:302)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:218)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:287)
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:103)
... 27 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.springframework.boot:spring-boot-maven-plugin:pom:1.5.11.RELEASE from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:287)
... 30 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework.boot:spring-boot-maven-plugin:pom:1.5.11.RELEASE from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version
How to resolve the Received fatal alert: protocol_version ? My java version is 1.7 and maven version is 3.3.3
Sonatype no longer supports TLSv1.1 and below (effective, June 18th, 2018). My guess is that you are using TLSv1.1 protocol or below.
The documentation I listed gives you 4 options:
Upgrade your Java runtime, for example with OpenJDK builds or Oracle paying support
Configure your Java runtime to enable TLS 1.2 by adding -Dhttps.protocols=TLSv1.2
Use a repository manager that uses a Java version supporting TLS 1.2
Revert back to http until you can acheive one of the above remediation steps.
I fixed it myself by just using -Dhttps.protocols=TLSv1.2 as a VM argument.
 
For a permanent solution(mostly required in Java 7) - in you build directory(where you do the mvn command from) add directory:
.mvn (in cmd mkdir .mvn)
and in it create file
jvm.config
and in put the following line:
-Dhttps.protocols=TLSv1.2
The simplest solution is to configure your JVM runtime arguments. On eclipse, you can do it as following :
go to windows>preferences>java>installed JREs
click on the Intalled JRE/JDK you are using for your project
click on "edit" on le right,
and add -Dhttps.protocols=TLSv1.2 in the Default VM arguments Input field.
see the screenshot :
The Package you are trying to install doesn't support TLS1.1 and you might be by default using TLS 1.1. Configure your Java runtime to enable TLS 1.2 by adding -Dhttps.protocols=TLSv1.2 to your Maven Build command would solve the problem.
For Example: mvn clean install -Dhttps.protocols=TLSv1.2
I had upgraded from Java 1.7 to Java 1.8 and got the same error.
To resolve this error, I checked the mvn version using mvn -version and found that JAVA_HOME was still using the Java 1.7. I changed the JAVA_HOME in the environment variable to point to Java 1.8 jre in JDK
Hope this helps someone.
I set my settings.xml file in the .m2 directory just as the one here: https://github.com/alipay/sofa-rpc/pull/190/files
Then exec mvn install and all dependencies started to download. I haven't had a settings.xml file before and I am not using any proxy.
Hope it helps somebody.
PD. I have jdk 1.7 and Maven 3.3.9
I resolved this error in SpringToolSuit by adding settings.xml file in .m2 folder which is located in Users folder of C drive and by updating Project by
right click on pom.xml -> Maeven -> Update Project.
Make sure you select Force update of snapshots/releases.
It needs both : Configuring the JVM runtime arguments as well as having a settings.xml, after I did both it worked. Updating only the JVM runtime argument did not help.
In my case the automatic update of maven dependencies were disabled in eclipse.
Solution:
Go to
Windows->Preferences->Maven
and uncheck the check box
"Do not automatically update dependencies from remote repositories"
Then update the project
Right click on project->maven->update project
I had the same issue, I tried most of the answers here but still did not work. My issue was Proxy settings on my IDE. So it is also important to remember to check proxy settings. File > Settings > System Settings > HTTP Proxy - Select Auto-Detect proxy settings
On my new laptop (Win10) I have downgraded maven 3.8.7->3.6.3 and jdk 19->1.8
Maven 3.8.7 is blocking a lot of old repositories, one sometimes does need.

Compilation error with maven

I have a compilation error in one of my projects
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
because it does not find all the classes from another project that I already included using
<dependency>
<groupId>com.laberint</groupId>
<artifactId>laberint-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
and I don't have any compilation problems from Eclipse. I already deleted all the repository.
The errors are because a missing classes that all are in the laberint-core artifact. I already deleted the whole repository folder
I also installed the jar
mvn install:install-file -Dfile=laberint-core-0.0.1-SNAPSHOT.jar -DgroupId=com.laberint -DartifactId=laberint-core -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar
Simply create a jar from your another project and add it in local lib directory of your current project. Another option is install the jar file in to your local maven repository like below:-
mvn install:yourlocal-jarfile
-Dfile=<path-to-your jar>
-DgroupId=<group-id> --> the group that the file should be registered under
-DartifactId=<artifact-id> --> give a artifact name to your jar
-Dversion=<version> --> version of your jar file
-Dpackaging=<packaging> --> jar
-DgeneratePom=true
Also you can try with below option:-
<dependency>
<groupId>com.laberint</groupId>
<artifactId>laberint-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<systemPath>/pathto/yourJar.jar</systemPath>
</dependency>
Hope this will help your. Good Luck!!!
As you stated in your comment you are developing the laberint-core project in the same Eclipse workspace as the project you are trying to build. The problem you have is that while Eclipse knows each project in your workspace and can resolve those project dependencies, Maven does not have this Information which means that it searches the repositories (your local one in ~/.m2 and Maven Central) for the dependency.
As you said, you have already installed the laberint-core project to your local Maven repository via mvn install. That's why Maven can find the dependency at all and you do not get a dependency could not be resolved exception but I would guess that you installed the dependency some time ago and so some of the classes that your created in the Eclipse project after installing are missing.
There are two ways how you can resolve this issue
Create and install the dependency jar each time before you build the main project
This means some more manual overhead when you are building the main project but it can be automated if you are only building in Eclipse and not directly from the command line.
Create an aggregator project as shown here.
This would basically be a third project that consists only of a pom.xml file that looks somewhat like this:
<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.laberint</groupId>
<artifactId>aggregator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>relative/path/to/laberint-core</module>
<module>relative/path/to/laberint-main</module>
</modules>
</project>
To build the project you would then call the goals you called on the main project before on the aggregator project. Basically if you called mvn package before from the root directory of the main project you would now change to the root directory of the aggregator project and call mvn package. By convention the aggregator pom should lay in the parent directory of its modules.

Maven 3 Eclipse Kepler is it necessary to have the environment variable to work for embedded Maven?

I have installed the last version of kepler the one has the maven embedded in it
when I tried many times to create application from any archetype
I always got
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Users\onourdean\.m2\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Users\onourdean\.m2\repository)
even though:
I have deleted the repository folder inside .m2 and its created again by it self
I have downloaded an external maven and used it
I made the proxy in sittings on both the embedded and the external
any other ideas? My settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>stsproxy</host>
<port>8080</port>
<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
</proxy>
</proxies>
<servers>
</servers>
<mirrors>
</mirrors>
<profiles>
</profiles>
</settings>
Note That:
i have tried all the soultions in the Create a Maven project in Eclipse complains "Could not resolve archetype" except making a variable for maven due to company restriction so is this variable necessary to run the embedded version?
Its seems there is a bug in the embedded version even if i use it outside of the proxy just used the external version
then use wagon-http-lightweight-2.2.jar as described in
Can access maven repository from behind proxy, need help
and its worked
I'm not sure if it's still the same with Kepler, but with earlier Eclipse (and M2E) releases this problem usually goes away if you go to Window -> Preferences -> Maven -> Installations and add your local, external Maven installation, which usually causes Eclipse to pick up the correct settings.xml file.

Categories

Resources