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>
Related
I'm trying to use Unirest in my program but I keep getting this error java.lang.NoSuchMethodError: com.google.gson.Gson.newBuilder()Lcom/google/gson/GsonBuilder;
I have tried using different maven versions of Gson but I still continue to get this seror
Edid added my pom.xml, I tried deleted my .m2 but I am still having this problem
<dependencies>
<!-- https://mvnrepository.com/artifact/com.konghq/unirest-java -->
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.7.00</version>
<classifier>standalone</classifier>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[4.0,)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>Spigot8</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar</systemPath>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<scope>compile</scope>
</dependency>
</dependencies>```
Could be a conflict between the GSON versions in your POM file versus what is in your container (Tomcat/JBoss) etc. Inspect the JARS in WEB-INF/lib. If there are two different versions, then delete the one which is not the same as the one currently in your maven project's POM file. I had a similar issue - my project was using gson-2.6.3.jar but a conflicting gson-2.1.jar also existed in WEB-INF/lib. I deleted gson-2.1.jar and this resolved my problem
This issue is possibly due to conflicts in Gson versions.
Go to your repository if you are on windows:
C:\Users\User_name.m2\repository\com\google\code\gson
or on Mac:-
/.m2/repository/com/google/code/gson
Delete all the existing folders.
Now, add below maven dependency in your pom file:
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
Re-build your maven project and try to run.
It seems like a dependencies issue.
Please make sure your dependencies are correct. Unirest 3.7.00 uses Gson 2.8.6
https://mvnrepository.com/artifact/com.konghq/unirest-java/3.7.00
Also, if you don't use Gson separately you don't need to specify it. Just add a dependency for unirest-java as it's described in Maven repository:
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.7.00</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 want add a new dependency into pom.xml. The eclipse shows the error: "Missing artifact presto:presto-jdbc:jar: 0.93"
I have tried to force update of snapshot. No fix.
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.29</version>
</dependency>
<dependency>
<groupId>presto</groupId>
<artifactId>presto-jdbc</artifactId>
<version>0.93</version>
</dependency>
</dependencies>
Are groupId, artifactId named arbitrarily? How can I fix this problem?(
No update dependency in Maven in my eclipse.)
Looking at maven central your dependency should be
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-jdbc</artifactId>
<version>0.93</version>
</dependency>
http://search.maven.org/#artifactdetails%7Ccom.facebook.presto%7Cpresto-jdbc%7C0.93%7Cjar
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>