I am trying to convert JSON to JAVA object with the use of GSON in MAVEN, I am following a youtube video for guidance - https://www.youtube.com/watch?v=Vqgghm9pWe0 , however theres an error which occurs when in the Main Class the error is - package com.squareup.okhttp3 doesn't exist. The code is below:
Java
package com.codebeasty.json;
import com.squareup.okhttp3.OkHttpClient;
public class Main {
private static OkHttpClient client = new OkHttpClient();
public static void main (String [] args)
{
}
}
I even put in the dependency in pom.xml:
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>
I dont understand why it doesn't recognize the com.squareup. Is there something extra I may need to download? I have downloaded the JAR from this website - http://square.github.io/okhttp/ and also tried building the project with dependencies. Please help :(
Maven repo has latest version 3.4.1. Trying changing version in pom or install downloaded in your local using
mvn install:install-file -Dfile=path/to/okhttp-3.4.2.jar -DgroupId=com.squareup.okhttp3 -DartifactId=okhttp -Dversion=3.4.2 -Dpackaging=jar
Related
I am trying to use jira-rest-java-client-api in my Jira server plugin.
I am using following versions,
Jira - 7.13.0
jira-rest-client. Version - 5.2.0
In my pom I have added jira-rest-java-client-api and jira-rest-java-client-core dependency like,
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>${jira-rest-client.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>${jira-rest-client.version}</version>
<scope>provided</scope>
</dependency>
I have added scope as provided so when I am building project using maven (atlas-mvn clean package) there is no error, but when I am trying to start the Jira server, my plugin is not added to Jira.
Getting following error
Unable to resolve 185.0: missing requirement [185.0]
osgi.wiring.package;
(osgi.wiring.package=com.atlassian.jira.rest.client.api)
Also, If I have not added the scope as provided then getting an error for banned dependencies while building using atlas-mvn clean package.
Any help would be appreciated, Thanks.
I was trying to build a project in Intellij-idea with Maven and got a error saying that
"Cannot resolve method 'combinations' in 'Sets'
The code where the error is showing is here :
public Set<Set<String>> GetCombinationsSet(){
System.out.println("Mapper: Calculating combinations");
ArrayList<String> resources = new ArrayList<>(timeHarMap.keySet());
Set<Set<String>> combinations = Sets.combinations(ImmutableSet.copyOf(resources), 2);
//System.out.println(combinations.toArray().length);
return combinations;
}
The imports im using :
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
I have guava dependency in the pom.xml, tried putting this dependency but it doesn't work:
<dependency>
<groupId>com.google.common</groupId>
<artifactId>google-collect</artifactId>
<version>0.5</version>
</dependency>
Image with the error when i try to build it :
try this in your pom.xml
<dependency>
<groupId>com.google.common</groupId>
<artifactId>google-collect</artifactId>
<version>1.0</version>
</dependency>
Cannot resolve image:
I am getting the error cannot resolve symbol jsonobject in intellij, shown in the attached image:Cannot resolve image, when I press Alt + Enter it does not give me the option to import class.
import org.json.JSONObject;
Please add this in your pom.xml file
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
Are you developing Java project through maven. If so approach shared by Alexandros Kourtis should work. If you are not using Maven, download the org.json library and reference it in the project.
For Gradle developers add this to to your build.gradle dependencies:
// https://mvnrepository.com/artifact/org.json/json
implementation 'org.json:json:20220924'
I want to add the firebase dependency on a java project of jhipster, I'm using eclipse, but when I add this dependency:
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>6.8.1</version>
</dependency>
that give Firebase, I get this error in my app in Java in eclipse:
The error 206 in english is:
the filename or extension is too long
I appreciate much your help
I want to try the example of dynamic update statement on this tutorial link : http://www.mybatis.org/mybatis-dynamic-sql/docs/update.html. I saw that it needs the import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; , So i've searched for dependency in the maven central and added below dependency on my pom.xml
<!-- https://mvnrepository.com/artifact/org.mybatis.dynamic-sql/mybatis-dynamic-sql -->
<dependency>
<groupId>org.mybatis.dynamic-sql</groupId>
<artifactId>mybatis-dynamic-sql</artifactId>
<version>1.0.0</version>
</dependency>
Already tried mvn clean install -U on maven build but still The import org.mybatis.dynamic cannot be resolved error always shows. Where can i have the correct maven dependency for this. Or you can suggest me other dynamic update statement approach on mybatis using xml mapper.
I also added the newest version of it and everything worked as expected. I had the problem, that mybatis-spring-boot-starter did not include mybatis-dynamic-sql.
<dependency>
<groupId>org.mybatis.dynamic-sql</groupId>
<artifactId>mybatis-dynamic-sql</artifactId>
<version>1.3.1</version>
</dependency>