Eclipse is unable to find and download the following jar:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-client</artifactId>
<version>4.1.2</version>
<packaging>pom</packaging>
</dependency>
http://search.maven.org/#artifactdetails|org.apache.httpcomponents|httpclient|4.1.2|jar
http://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-client/4.1.2/httpcomponents-client-4.1.2.jar
Resolved: I dunno where the pom came from.
Is missing.
It's not missing.
That's a pom (Project Object Model) file.
You probably want the httpclient jar. The pom describes the total project (multiple jar files).
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
</dependency>
Related
I'm facing some strange problem.
During maven build I'm getting package io.rsocket.core does not exist.
My pom.xml contains following dependencies
<dependency>
<groupId>io.rsocket</groupId>
<artifactId>rsocket-core</artifactId>
<version>1.0.0-RC6</version>
</dependency>
<dependency>
<groupId>io.rsocket</groupId>
<artifactId>rsocket-transport-netty</artifactId>
<version>1.0.0-RC6</version>
</dependency>
Analyzing reactor-core jar file showes that there is no core package in that jar. Did I missed some dependencies?
Thanks
Package is found in the artifact (spring-cloud-function-rsocket) Add this to your pom:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-rsocket</artifactId>
<version>3.1.0-SNAPSHOT</version>
</dependency>
I am using pom.xml like
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
but there is no .jar available in public repo. It have only .pom file in respective release. Public maven repository link
How to get .jar for it.
You can manually download .zip for respective release from jackson-modules-java8/releases
and build it locally using command.
mvn clean install
It will give you .jar for each module under respective target directory.
You need to also include that dependency in your pom.xml:
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-modules-java8</artifactId>
<version><!-- same version as your other jackson dependencies --></version>
</dependency>
In Eclipse, when I go to myProject -> right click -> Run As -> Maven build, I am getting multiple errors in the console outlining that certain packages does not exist, like:
javax.ws.rs does not exist
javax.ws.rs.core does not exist
javax.servlet does not exist
javax.servlet.http doest not exist
Although in my pom.xml, I have provided those dependencies:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
<version>1.0</version>
</dependency>
etc
under
<dependencyManagement><dependecies>
tags (don't have any errors in pom.xml).
I do also have proxy settings configured in settings.xml file, and this file is properly linked.
I've also got these jars included locally to WebContent\WEB-INF\lib folder and added to the classpath (I can run my REST service on tomcat, the error "package does not exist" appears only when I am trying to use Maven build".
The reason I need that I want to generate and deploy a .war file.
How I can solve this? Is there a war to force Maven look in local libraries instead?
If you have:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
then you need to have a separate:
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</dependency>
</dependencies>
section.
Typically you would define dependencyManagement in a parent pom.xml file and then use the second dependencies fragment in child pom.xml files. This ensures that all your modules depend upon the same consistent artifacts.
I have a Java project that uses http common-logging.jar, httpclient-4.4-alpha1.jar, httpcore-4.4-alpha1.jar, httpmime-4.4-alpha1.jar. I converted my Java project to a Maven project and added the above jar files to my pom.xml. This is my 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyClient</groupId>
<artifactId>MyClient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
</build>
</project>
I did Run As > Maven Clean and Run As > Maven Install and it built the project. It generated a jar file in the target folder called MyClient-0.0.1-SNAPSHOT.jar. I added this jar to another project that uses this jar file (to make HTTP calls) and I get the error
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/http/entity/mime/content/ContentBody
Can someone tell me what is causing this? This seems to like a dependancy issue? Can someone tell me what I am doing wrong?
Maven will not automatically package these dependencies into your jar file. These files are only used to compile the code and build the jar file itself. As the documentation for the jar plugin states:
The resulting 'jar' file contains the compiled java class files as well as the files from src/main/resources.
You have a number of options:
Package your MyClient jar file as a "fat" jar using something like the maven shade plugin
Add the dependencies from the MyClient POM to the POM in the project that uses the jar file.
Use a maven multi-module project with a common parent so that transitive dependencies such as this are resolved between the projects.
Manually copy all of those jar files over when you copy the MyClient jar file
Hi guys wondering if you can let me know where I am going wrong.
In my pom.xml I added a dependency for org.powermock:powermock-mockito-release-full:jar:1.5.4
via the following:
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-mockito-release-full</artifactId>
<version>1.5.4</version>
<scope>test</scope>
</dependency>
Now during a build I get the error "Could not resolve dependencies for project com.law:test_pro:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.powermock:powermock-mockito-release-full:jar:1.5.4"
In my local repository I have all jars for containing sub-projects but no jar for the parent jar which the build process seems to be looking for.
There is only a parent pom file available for the Maven co-ordinate
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-mockito-release-full</artifactId>
<version>1.5.4</version>
<scope>test</scope>
</dependency>
Hence, you need to add the type 'pom' to this like so:
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-mockito-release-full</artifactId>
<version>1.5.4</version>
<scope>test</scope>
<type>pom</type>
</dependency>