This is my pom.xml
<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>cassandra</groupId>
<artifactId>connector</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>cassandra</name>
<description>cassandra connector</description>
<dependencies>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>2.1.5</version>
</dependency>
</dependencies>
</project>
Error is shown at line 12.
I have copied and pasted the maven dependency from here.
http://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core/2.1.5
One way to get rid of this error is by downloading bundle file on your local machine from below URL & try below mvn:install command to update it on your local repository.
http://central.maven.org/maven2/com/datastax/cassandra/cassandra-driver-core/2.1.5/cassandra-driver-core-2.1.5.jar
mvn install:install-file -Dfile="cassandra-driver-core-2.1.5.jar" -DgroupId=com.datastax.cassandra -DartifactId=cassandra-driver-core -Dversion=2.1.5 -Dpackaging=jar
Or other way, if you are connecting to Maven repository like Nexus & having rights to update your repository then you can deploy your bundle to Nexus using below mvn:deploy command.
mvn deploy:deploy-file -Durl=http://<>:<>/nexus/content/groups/public -DrepositoryId=nexuspublic -Dfile="cassandra-driver-core-2.1.5.jar" -DgroupId=com.datastax.cassandra -DartifactId=cassandra-driver-core -Dversion=2.1.5 -Dpackaging=jar
In my case I figured out two issues causing this problem, firstly older versions usually throws such errors, so make sure to use the latest version of the dependency. Secondly, using nexus instead of maven repository fixed my issue and it does not say "missing artifact" anymore, I figured this out when I saw a note in https://mvnrepository.com/artifact/pentaho-kettle/kettle-engine/9.3.0.0-115
indicating that the artifact is actually in nexus repository. Lastly, try to be consistent with your versions, for instance, if your using multiple dependencies for the same bundle, stick with the same version as they are most compatible with each other I believe (preferably latest version).
Related
I am completely new to Maven. I am using eclipse 2021-12 and i am trying to follow the installation from this link but do it in eclipse.
However, i am struggling to carry out the first step in eclipse "Install library into your Maven's local repository by running mvn install". I have created a new simple Maven Project and added the dependency code in step 2. And it gave me an error saying missing jar file.
My question is how do i carry out step 1 in eclipse ?
This is how the pom.xml looks like:
<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>binance.crypto</groupId>
<artifactId>binance.crypto</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.binance.api</groupId>
<artifactId>binance-api-client</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
The error i am getting is missing artifact com.binance.api:binance-api-client:jar:1.0.0:
Solution:
Clone the project from github and import as a normal project (not maven project) in eclipse
Right Click and run as Maven Install
Then it's completed
I have a Maven project which has a dependency on an Oracle JDBC library i.e. the entry in the project pom.xml is
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
I have a copy of this project on 2 different machines; one running Windows 7 and one running Windows 10 (the version of Maven is the same; 3.6.3 and the required dependency exists in the default local repository; .m2\repository\com\oracle\ojdbc7\12.1.0.2\ojdbc7-12.1.0.2.jar)
When I run mvn clean package on the Windows 10 machine, no errors are returned and the relevant target files are created. However, when I run mvn clean package on the Windows 7 machine, an error occurs complaining about a missing dependency POM file; ojdbc7-12.1.0.2.pom.
I can work around this problem by manually creating this file on the Windows 7 machine, i.e.
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2.0</version>
</project>
I don't understand why I need to do this!!????
ojbdb7 is not part of official Maven repositories.
You need to add it manually to your company repository or to your local repository.
I assume that one of your local repositories has it and the other one doesn't.
Try to use the latest Oracle JDBC driver which is 21.1.0.0.
If you have JDK8, then you can use ojdbc8.jar from 12.2.0.1
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
I am new with Maven and Spark and I would like to play a bit with both of them.
I am on OSx so I've installed both using brew.
On eclipse I created a Maven project with the quick wizard and created the following pom.xml
<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.and.app</groupId>
<artifactId>myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.4.3</version>
</dependency>
</dependencies>
</project>
while the main class is:
package myapp;
import static spark.Spark.*;
public class Driver {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World"); }
}
But I get the following error:
Missing artifact com.sparkjava:spark-core:jar:2.4.3
I thought it was because of the brew installation and so I've add the line:
<systemPath>\usr\local\Cellar\apache-spark\2.4.3\libexec\jars</systemPath>
as an explicit path for spark jars just after the version tag in the pom.xml
Until now I have no success.
What am I doing wrong?
P.S.: I verified Maven and Spark installation.
Maven is getting the dependencies automatically from the network. If you want it to use locally installed jars, you have to add them to your local maven repository:
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
But I am wondering: You could also tell maven to get the spark dependency itself. It seems to be available for maven users:
https://mvnrepository.com/artifact/org.apache.spark/spark-core
So the dependency should be:
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>2.4.3</version>
</dependency>
Check the definition of the system scope:
This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
It means that you should provide the path to jar for each launch of your code. And for compilation as well (because of import). Change the scope or provide the path to the jar for compiler explicitly.
https://github.com/bvanalderweireldt/concurrent-unique-queue
I have tried to set up a Maven dependency within IntelliJ, but I am not sure how the contents of this repository should be built and imported into a Java project. Could someone with more experience please advise on how this is done?
Kind regards,
L
If you want to use this project in another project, you will create a dependency to this using the dependency entry mentioned on the github readme:
<dependency>
<groupId>com.hybhub</groupId>
<artifactId>concurrent-util</artifactId>
<version>0.1</version>
</dependency>
For this, you need the artifact in your local maven repository*. For this, you need to build this project or use a reference from Maven Central (Thanks #Mark Rotteveel )
Clone the project locally, you need to build it in one of the following ways
Build it from the command line: Navigate to the project's location in your shell (bash or cmd) and run mvn install
This will build the project and add the artifact (jar) to the local .m2 repository.
Import to Intellij Idea (File -> New -> From Existing Sources). Once imported, build this project from the "Maven Projects" view.
Once you have done this, you can use this in other projects using the <dependency> entries
*For production ready apps, you may want to have a common maven repository for team your like Nexus or Artifactory and use that to maintain artifacts. You would also have a build system like Jenkins.
In the link you gave it had the dependency Maven entry for that library.
<dependency>
<groupId>com.hybhub</groupId>
<artifactId>concurrent-util</artifactId>
<version>0.1</version>
</dependency>
That entry would need to be nested into you <dependencies> tag. Like the example below.
<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.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.hybhub</groupId>
<artifactId>concurrent-util</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
If I wanted to use just the normal git via the command line and not the one in IntelliJ, what do I need to include in the version control so when I download it, I can get the Maven libraries without manually installing them?
Edit: There is no pom.xml file when the libraries are added to an IntelliJ project, so I was wondering what I need to include so Maven inside IntelliJ can download the libraries.
what do I need to include in the version control so when I download it, I can get the Maven libraries without manually installing them?
The pom.xml file does this:
Some of the configuration that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on. Other information such as the project version, description, developers, mailing lists and such can also be specified.
Running mvn install will cause Maven to download your dependencies.
Intellij will automatically understand the changes in the pom files and update libraries of course you should have pom.xml file.
If its a maven based project, you definitely need a pom.xml file like below
<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.test</groupId>
<artifactId>testing</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>testing</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Once you have a pom.xml file, you can define dependencies like the JUnit dependency defined above with the version you need and maven will automatically take care of downloading the dependency for the project. Once you add any new dependency to the pom.xml, you can run "mvn clean install" from the directory where you have the pom.xml file so that it installs the new dependency.
Hope this helps.