This is a really simple question, but I searched for a resolution and nothing is working for me. I added the below to my pom.xml, but can't import org.apache.commons.csv.CSVParser in my class. When I run mvn install, I get the below output.
<dependencies>
....
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.1.1-SNAPSHOT</version>
</dependency>
....
</dependencies>
D:\java\my_project>mvn install
[INFO] Scanning for projects...
[INFO] Building my_project 1.0-SNAPSHOT
[WARNING] The POM for org.apache.commons:commons-csv:jar:1.1.1-SNAPSHOT is missing, no dependency information available
[INFO] BUILD FAILURE
[INFO] Total time: 0.644 s
[INFO] Finished at: 2015-07-21T08:46:47-04:00
[INFO] Final Memory: 8M/245M
[ERROR] Failed to execute goal on project my_project: Could not resolve depen dencies for project com.myproject:artifact:jar:1.0-SNAPSHOT: Could not find artifact org.apache.commons:commons-csv:jar:1.1.1-SNAPSHOT -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException nException
Why are you using the snapshot? The snapshot version is a alpha/beta version, which might be unstable. It's also not uploaded to the standard Maven repo, so you would need to do some extra work to use it. If you use 1.1 it should work.
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.1</version>
</dependency>
Related
I want to skip demo-api (Which is another module) during build. Setting optional true doesn't work. Any suggestions on how to skip it but not delete the dependency from pom.xml?
Failed to execute goal on project [36mdemo-web[m: [1;31mCould not resolve dependencies for project demo-web:demo-web:war:1.0-SNAPSHOT: Failed to collect dependencies at demo-api:demo-api:jar:1.0-SNAPSHOT[m: Failed to read artifact descriptor for demo-api:demo-api:jar:1.0-SNAPSHOT: Could not find artifact demo-spring-boot:demo-spring-boot:pom:1.0-SNAPSHOT
<dependency>
<artifactId>demo-api</artifactId>
<groupId>demo-api</groupId>
<version>1.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
You can put that dependency in a profile:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.foo</groupId>
<artifactId>foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>foo</name>
<profiles>
<profile>
<id>includeBadDependency</id>
<dependencies>
<dependency>
<artifactId>demo-api</artifactId>
<groupId>demo-api</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
</profiles>
<!-- Normal dependencies go here-->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.5.RELEASE</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
When you build this project:
$ mvn verify # this will succeed
$ mvn verify -PincludeBadDependency
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< org.foo:foo >-----------------------------
[INFO] Building foo 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from maven-atlassian-com: https://packages.atlassian.com/maven/repository/internal/demo-api/demo-api/1.0-SNAPSHOT/maven-metadata.xml
Downloading from maven-atlassian-com: https://packages.atlassian.com/maven/repository/internal/demo-api/demo-api/1.0-SNAPSHOT/demo-api-1.0-SNAPSHOT.pom
[WARNING] The POM for demo-api:demo-api:jar:1.0-SNAPSHOT is missing, no dependency information available
Downloading from maven-atlassian-com: https://packages.atlassian.com/maven/repository/internal/demo-api/demo-api/1.0-SNAPSHOT/demo-api-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.434 s
[INFO] Finished at: 2021-09-21T18:24:24+10:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project foo: Could not resolve dependencies for project org.foo:foo:jar:1.0.0-SNAPSHOT: Could not find artifact demo-api:demo-api:jar:1.0-SNAPSHOT in maven-atlassian-com (https://packages.atlassian.com/maven/repository/internal) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
Maybe this can give you a hint or two.
<scope>runtime</scope>
I think this will do the trick
I'm upgrading my microservice from version 1.5.4 to 2.5.2.
I am having the current issue when building the project. From what I understood, this can happen becouse there is something wrong with the dependencies or sources of a project.
This release spring boot upgrades to Hazelcast 4 whilst keeping compatibility with Hazelcast 3.2.x. If you’re not ready to switch to Hazelcast 4, you can downgrade using the hazelcast.version property in your build. Having our application in version 3.10.2, this library will not be upgraded within the context of this user story.
However, I'm having the following issue:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Repo/microservices/eco-microservices/functional/translator-service/src/main/java/com/economical/microservices/translator/config/HazelcastConfiguration.java:[10,28] cannot find symbol
symbol: class MaxSizeConfig
location: package com.hazelcast.config
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.408 s
[INFO] Finished at: 2021-08-06T21:46:04+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project translator-service: Compilation failure
[ERROR] /C:/Repo/microservices/eco-microservices/functional/translator-service/src/main/java/com/economical/microservices/translator/config/HazelcastConfiguration.java:[10,28] cannot find symbol
[ERROR] symbol: class MaxSizeConfig
[ERROR] location: package com.hazelcast.config
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Follows a pom file snippet:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<!-- Spring Framework Caching Support -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
</dependency>
<!-- JSON Libraries -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>
<!-- Spring Data JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Can you please help me understand what the issue is?
You are not defining what version of the dependencies you are using. In the latest version of Hazelcast there seems not to be any MaxSizeConfig class any longer.
I am trying to download all transitive dependencies and plugins for a pom file into a local folder and then using it to run sonarqube offline. I am fairly new to Maven, so I might be doing something wrong here, but I think maven maven-dependency-plugin:3.1.1:go-offline is not downloading all plugins needed to run sonarqube, which is causing an error.
This is what I have tried.
Download all dependcies to a new folder
mvn -D"maven.repo.local"="c:\test\test" org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
run sonar
mvn -o -D"maven.repo.local"="c:\test\test" sonar:sonar
This however gives me the following error
[INFO] Scanning for projects...
[WARNING] The POM for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-antrun-plugin:jar:1.3 has not been downloaded from it before.
[WARNING] The POM for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5 has not been downloaded from it before.
[WARNING] The POM for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 has not been downloaded from it before.
[WARNING] The POM for org.apache.maven.plugins:maven-release-plugin:jar:2.5.3 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.5.3: Plugin org.apache.maven.plugins:maven-release-plugin:2.5.3 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-release-plugin:jar:2.5.3 has not been downloaded from it before.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.133 s
[INFO] Finished at: 2019-04-30T14:35:43+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'sonar' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (c:\test\test), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
The POM file is as below
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>HelloWorld</groupId>
<artifactId>HelloWorld_Test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
</dependency>
</dependencies>
</project>
Since it is complaining about various plugins not being available, I gather there is a problem with the maven-dependency-plugin not downloading all necessary plugins needed to run sonarqube ? Any ideas how to get around this?
sonar-maven-plugin should be declared as a plugin and not as a dependency.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
</plugin>
</plugins>
</pluginManagement>
</build>
I am new to Maven and I am trying to create a JAR out of a HelloWorld program.
I have done the classpath setting:
This is the pom.xml file:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>custom-project</artifactId>
<packaging>maven-plugin</packaging>
<version>1.0</version>
<name>custom-project Maven Mojo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
When I trigger mvn package command, I am getting this error:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.700 s
[INFO] Finished at: 2018-04-13T12:25:12+05:30
[INFO] Final Memory: 9M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project custom-project: Compilation f
ailure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
JAVA_HOME is already set as C:\Program Files\Java\jdk1.8.0_121\bin in classpath. Please suggest how to resolve this issue.
Your JAVA_HOME is set to a JRE not to a JDK. The JRE does not include the Java Compiler, so set JAVA_HOME to a JDK and it should work
Also you can goto your project properties-> Libraries-> add Library -> JRE system Library -> Alternate JRE -> Add.
and then you choose your JDK path from your system and apply.
Make sure to remove JRE From project library.
In my case, this works well.
You need to tell java what class to run. Depending on the maven plugin you use the ways might be different. This link shows how it can be done with the help of the maven-assembly-plugin https://stackoverflow.com/a/45902851/6825678
I am new to Maven and would love some help with an issue I've been having. I am not able to compile one of my projects due to an Illegal Argument Exception for one of the dependency URLs. Here is my pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="https://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>
<name>MDM-Map-Reduce</name>
<groupId>com.cardinalhealth</groupId>
<artifactId>MDM-Map-Reduce</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>hortonworks</id>
<url>
http://repo.hortonworks.com/content/repositories/releases/
</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.hcatalog</groupId>
<artifactId>hcatalog-core</artifactId>
<version>0.5.0.21</version>
</dependency>
</dependencies>
</project>
And here is the last few lines of the output from mvn clean install:
Downloading: http://repo.hortonworks.com/content/repositories/releases/org/apache/hcatalog/hcatalog-core/0.5.0.21/hcatalog-core-0.5.0.21.pom
4/4 KB
Downloaded: http://repo.hortonworks.com/content/repositories/releases/org/apache/hcatalog/hcatalog-core/0.5.0.21/hcatalog-core-0.5.0.21.pom (4 KB at 28.4 KB/sec)
Downloading: http://repo.hortonworks.com/content/repositories/releases/org/apache/hcatalog/hcatalog/${hcatalog.version}/hcatalog-${hcatalog.version}.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/hcatalog/hcatalog/${hcatalog.version}/hcatalog-${hcatalog.version}.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.895 s
[INFO] Finished at: 2014-05-13T17:52:15-05:00
[INFO] Final Memory: 5M/12M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project MDM-Map-Reduce: Could not resolve dependencies for project com.cardinalhealth:MDM-Map-Reduce:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.apache.hcatalog:hcatalog-core:jar:0.5.0.21: Failed to read artifact descriptor for org.apache.hcatalog:hcatalog-core:jar:0.5.0.21: Could not transfer artifact org.apache.hcatalog:hcatalog:pom:${hcatalog.version} from/to hortonworks (http://repo.hortonworks.com/content/repositories/releases/): IllegalArgumentException: Illegal character in path at index 88: http://repo.hortonworks.com/content/repositories/releases/org/apache/hcatalog/hcatalog/${hcatalog.version}/hcatalog-${hcatalog.version}.pom -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
(I had to break the urls after http:// with a space for SO to allow me to post)
If you notice it seems like it is trying to pull the same dependency twice, I have no clue why it would do that, or why it would fail to resolve parameters correctly.
I have attached relevant files here, I am a complete Maven novice so I have included the directory layout (in list), the pom and the output of mvn clean install, both standard and extended (i.e. with -e for stack trace).
https://drive.google.com/folderview?id=0B_G2bKn27T9raFVoMkl0LUQyT28&usp=sharing
use pluginrepo instead repository
e.g.
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>http://repository.apache.org/snapshots/</url>
</pluginRepository>
</pluginRepositories>