I am trying to import jersey using maven central but, intellij wont read my pom.xml dependency for jersey. The version # shows in red with the following error:
here is the pom.xml textually:
<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.example.emanuel</groupId>
<artifactId>jerseyexample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jerseyexample Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.19</version>
</dependency>
</dependencies>
<build>
<finalName>jerseyexample</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>TomcatServer</server>
<path>/newjersey</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
i copied the dependency straight from here
the issue was with my settings.xml file that maven uses to build the project. I had a mirror defined in there that used a proxy and it was blocking the download.
Related
I have .Jar file with only .class files in there without any .java files...
I cloned a git repository:
https://github.com/kaist-dmlab/k-Medoid/tree/master/MR-KMEDIAN
the repository has a .jar file as well, but no .pom file with the java code. So I created a Maven Project in Eclipse, created a package: com.parallel.WEIGHTED_KMEDIAN
and put the files in there. This is what the directory looks like:
I checked all the dependencies in the java files and looked them up on the maven website and added them. So my pom.xml file looks 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.parallel</groupId>
<artifactId>WEIGHTED_KMEDIAN</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>WEIGHTED_KMEDIAN</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-model</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>8</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I run the .jar file on AZURE HDINSIGHTS I get an error:
When I compared the .jar file I created and the one in the project, I am missing all the .java files.
Is this the issue that azure doesn't like?
How can I add the .java files in the .jar file?
I created the jar file from eclipse going into run>maven build> clean install
files in my jar:
files in jar from git repo:
so far I have tried:
<sourceDirectory>src/main/java/com/parallel</sourceDirectory>
Updating MAVEN project
clean compile install
The solution was the project directory needed to be in a specific format, it should be under main/resources and then follow the path in the groupID specified in the POM.xml file:
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.parallel</groupId>
<artifactId>WEIGHTED_KMEDIAN</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>WEIGHTED_KMEDIAN</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-model</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>8</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
Dependencies:
I have problem by running Maven-Project from command_line
I used this command in cmd to run class named mainClass
mvn -e exec:java -Dexec.mainClass="com.example.Main"
and here is what I have in my pom 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>Linux</groupId>
<artifactId>Linux</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.37.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<!-- Needs to be the same version that REST Assured depends on -->
<version>2.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
</dependency>
</dependencies>
</project>
I get Mojo Exception caused by class not found exception, but actually I don't know where I should provide the name or the path to the class I want to run
this is the response of the command in command-line
I have modified your Maven pom.xml and added Maven mojo plugin. You can find below the code.
First you have to build project and then you can execute the Main java class.
Here, follow the steps.
Go to command prompt and go to the project/directory containing pom.xml.
Type the command mvnw clean package. I have used maven wrapper.
Then type command mvnw exec:java -Dexec.mainClass="com.so.help.maven.Main"
You can find the sample project in github.
<?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>execute-java-maven</groupId>
<artifactId>execute-java-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<name>execute-java-maven</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.37.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<!-- Needs to be the same version that REST Assured depends on -->
<version>2.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>com.so.help.maven.Main</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I have an Eclipse / Maven project: The build with Maven succeeds, but Eclipse does have compile-time errors and cannot build.
My Eclipse is Neon (4.6.3) and I am using the build-in Maven and JDK 1.8
Could you help me solve the problem?
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>seller</groupId>
<artifactId>home.digest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>home.digest Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.11</version>
</dependency>
<dependency>
<!-- jsoup HTML parser library # https://jsoup.org/ -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
</dependencies>
<build>
<finalName>home.digest</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Eclipse fails to recognize the following imports in a class:
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.protocol.HttpContext;
The Eclipse project has the following properties:
The problem was, that the jar file was corrupt:
[ERROR] error reading C:\Users\User.m2\repository\org\apache\httpcomponents\httpcore\4.4.11\httpcore-4.4.11.jar; invalid LOC header (bad signature)
I solved the problem by replacing the dependency
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.11</version>
</dependency>
by the dependency on an earlier version:
4.4.10
Hello
First of all, You should check to contain the apache jar file your maven local folder. Some version folder have in your local maven folder. But doesn't have jar file.
OR
this line code add to your pom.xml file.
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
I tried to follow a tutorial but, I got an error with maven right from the first step.
Failure to transfer org.codehaus.plexus:plexus-archiver:pom:1.2 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will
not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.plexus:plexus-
archiver:pom:1.2 from/to central (http://repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/maven2/org/codehaus/
plexus/plexus-archiver/1.2/plexus-archiver-1.2.pom
My pom.xml is as follow:
<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.dictionnaire.allemand</groupId>
<artifactId>translator</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>translator Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>translator</finalName>
</build>
</project>
i tried many sollutions like
mvn -U install
but without success. have you any idea how can i fix this error? im working with eclipse-Kepler for java EE devlopper. and i don't working behind a proxy or a firewall.
here is the content of http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/1.2/plexus-archiver-1.2.pom
<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>
<parent>
<artifactId>plexus-components</artifactId>
<groupId>org.codehaus.plexus</groupId>
<version>1.1.18</version>
</parent>
<artifactId>plexus-archiver</artifactId>
<version>1.2</version>
<name>Plexus Archiver Component</name>
<scm>
<connection>
scm:svn:http://svn.codehaus.org/plexus/plexus-components/tags/plexus- archiver-1.2
</connection>
<developerConnection>
scm:svn:https://svn.codehaus.org/plexus/plexus-components/tags/plexus- archiver-1.2
</developerConnection>
<url>
http://fisheye.codehaus.org/browse/plexus/plexus- components/tags/plexus-archiver-1.2
</url>
</scm>
<properties>
<useJvmChmod>false</useJvmChmod>
</properties>
<contributors>
<contributor>
<name>Dan Tran</name>
</contributor>
<contributor>
<name>Richard van der Hoff</name>
</contributor>
</contributors>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-io</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<systemPropertyVariables>
<useJvmChmod>${useJvmChmod}</useJvmChmod>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
I want to try something new and use Dagger 2 as my DI framework. So I have the following pom and the "hello world" coffee maker classes (http://google.github.io/dagger/) in my projekt.
But when I do a mvn clean install no classes get generated. As far as I unterstood there should be a "Dagger_CoffeeShop" class generated. Hmmm ... what am I missing?
<modelVersion>4.0.0</modelVersion>
<groupId>kic</groupId>
<artifactId>xfoo</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
For those using Gradle: Make sure you are referencing the Dagger dependencies as following:
compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.2'
And in the case if you are running into apt not supported, add
1) Into module app\build.gradle:
apply plugin: 'com.neenbedankt.android-apt'
2) Into project \build.gradle:
buildscript {
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
I had the same problem, only with the release version 2.0.
In my case the following two steps solved this problem:
Adding target/generated-sources/annotations to my build path
Adding <forceJavacCompilerUse>true</forceJavacCompilerUse> to the maven compiler plugin
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- workaround for https://issues.apache.org/jira/browse/MCOMPILER-202 -->
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
</plugin>
See also:
https://github.com/google/dagger/pull/103
https://issues.apache.org/jira/browse/MCOMPILER-202
This isn't the best answer. When I used the downloaded JAR files (commented out in the POM file below) mine also wasn't generating the Dagger_ files. Once I added the repository to the POM, everything was working fine.
<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.hello</groupId>
<artifactId>hellodagger</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hellodagger</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>sonatype</id>
<name>sonatype-repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>2.0-SNAPSHOT</version>
<!--<scope>system</scope>-->
<!--<systemPath>${project.basedir}/dagger-2.0-20141216.223138-12.jar</systemPath>-->
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.0-SNAPSHOT</version>
<optional>true</optional>
<!--<scope>system</scope>-->
<!--<systemPath>${project.basedir}/dagger-compiler-2.0-20141216.223201-12-jar-with-dependencies.jar</systemPath>-->
</dependency>
</dependencies>
</project>