Imported Git Repository but some imports are not found? - spring

I have a Git Repository that I imported into Eclipse but it has some import errors.
I'm using Spring Redis version 1.8.4 and following their examples on how to do object mapping. I used the Jackson Mapper link and then followed that to the jackson-datatype-mongo mapper.
https://github.com/commercehub-oss/jackson-datatype-mongo
On my work computer everything is fine.
<dependency>
<groupId>com.commercehub.jackson</groupId>
<artifactId>jackson-datatype-mongo</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.8.4.RELEASE</version>
</dependency>
If I remove the jackson-datatype-mongo dependency then the imports are fine but then I wouldn't have the MongoModule import. I tried one of eclipse's solutions and it said that it could an archive 'jackson-databind-2.8.1.jar' and everything would be clear. But then my '.classpath' file is now changed.
I don't understand how it is fine on one machine and all I did was clone the repository into another machine.

I solved the issue. I checked libraries in the project and it showed that the class was in there. So I went into '.m2\repository\com\fasterxml\jackson\core' and deleted the whole 'jackson-databind' folder and restarted eclipse and all the imports were now resolved.

Related

Dependency for driver-class com.ibm.db2.jcc.DB2Driver is missing

i added the followinig dependency for my project to connect to the database:
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc4</artifactId>
<version>4.19.26</version>
</dependency>
Since the connection to my database gets refused (ERRORCODE=-4499, SQLSTATE=08001) i tried to add a newer driver
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc4</artifactId>
<version>11.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/com/ibm/db2/jcc/db2jcc4/11.1/db2jcc4-11.1.jar</systemPath>
</dependency>
I installed the jar with the maven install comand in my project directory. It created a lib folder with everything in it.
However i now get the following error:
Dependency for driver-class com.ibm.db2.jcc.DB2Driver is missing!
The maven project is definitly able to locate the jar-file.
There is a second dependency you are missing :
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc_license_cu</artifactId>
<version>11.1</version>
<systemPath>${basedir}/lib/com/ibm/db2/jcc/db2jcc4/11.1/db2jcc_license_cu.jar</systemPath>
</dependency>
Found on nacho4d's blog

Ratpack 1.5.4 hystrix dependency cannot be resolved

I cannot compile my project that uses Ratpack 1.5.4 because there is a missing dependency to Hystrix 1.5.13 which cannot be resolved.
http://search.maven.org/#search%7Cga%7C1%7Cg%3A"com.netflix.hystrix"%20AND%20v%3A"1.5.13"
What is wrong here?
You can try excluding com.netflix:hystrix-core:1.5.13 from io.ratpack:ratpack-hystrix:1.5.4 and then you can add com.netflix:hystrix-core:1.5.12 directly to your pom.xml file, something like that:
<dependencies>
<dependency>
<groupId>io.ratpack</groupId>
<artifactId>ratpack-core</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>io.ratpack</groupId>
<artifactId>ratpack-hystrix</artifactId>
<version>1.5.4</version>
<exclusions>
<exclusion>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
<version>1.5.12</version>
</dependency>
</dependencies>
I've tested this simple Maven Ratpack "Hello, World!" app https://github.com/wololock/ratpack-maven-example
It compiles in Travis without any issue - https://travis-ci.org/wololock/ratpack-maven-example (I have com.netflix:hystrix-core:1.5.13 in my local .m2 repository, so I wanted to use something with a clean local Maven repository like Travis CI)
I don't know if version 1.5.13 got rolled back or something like that. It can be found in MvnRepository.com https://mvnrepository.com/artifact/com.netflix.hystrix/hystrix-core/1.5.13 however it says that 1.5.12 is newer, even though it got released 2 months earlier.

Maven dependency for javax.mail

What is the maven dependency i should add for
import javax.mail.*;
import javax.mail.internet.*;
Adding the maven dependency from here http://mvnrepository.com/artifact/javax.mail/mail/1.5.0-b01 makes some of the jersey dependencies unable to retrieve error. What do you think is going wrong?
The version 1.6.3 had been the last version of JavaMail; since 2019-07-03, the new name for it is "Jakarta Mail".
Together with the name change also the Maven coordinates got different:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>…</version>
</dependency>
The project homepage can be found here: https://eclipse-ee4j.github.io/mail/
We are using following dependency:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>

Postgresql driver not found for maven dependency

I am running a spring project with maven and I am trying to use postgresql. I've added the dependency to pom.xml, but at tomcat startup, I get the following error:
java.lang.ClassNotFoundException: org.postgresql.Driver
pom.xml dependency:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1101-jdbc41</version>
</dependency>
It appears that Maven isn't downloading the jar so the Driver class is not found. Any ideas?
What also worked for me if you are on intellj:
right klick pom.xml->Maven->Reimport
Don't know why it doesn't download the artifact on copy paste.
When I put this in my pom, the artifact gets downloaded. Maybe you should clean your maven repository cache or delete the folders manually and retry.
If you came here for "missing artifact" error, This worked for me:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1212</version>
</dependency>
For PostgreSQL 10 I use this:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.4</version>
</dependency>
Maven wasn't recognizing the new dependency I have added to pom.xml, so I added it through 'Dependency view' from the xml and that did the trick. Thank you for your answers.
Try to rebuild the artifact, most likely only the added dependency was not included there
You need to place a copy of the jar in the tomcat/lib folder.

What dependency is missing for org.springframework.web.bind.annotation.RequestMapping?

What dependency am I missing? I am currently using:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
The error Im getting is:
The import org.springframework.web.bind cannot be resolved
I had the same problem. After spending hours, I came across the solution that I already added dependency for "spring-webmvc" but missed for "spring-web". So just add the below dependency to resolve this issue. If you already have, just update both to the latest version. It will work for sure.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
You could update the version to "5.1.2" or latest. I used V4.1.6 therefore the build was failing, because this is an old version (one might face compatibility issues).
This solution WORKS , I had the same issue and after hours I came up to this:
(1) Go to your pom.xml
(2) Add this Dependency :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
(3) Run your Project
the problem's actually caused by dependency. I spent whole the day to solve this prblm.
Firstly, right click on project > Maven > add dependency
In "EnterGroupId, ArtifactId, or sha1...." box, type "org.springframework".
Then, from droped down list, expand "spring-web" list > Choose the newest version of jar file > Click OK.Done!!!
I don't think the problem is the dependencies. I guess you are getting that error on your IDE. Then just refresh it. If it's eclipse, try running Maven->Update Dependencies
To resolve, Update Spring Frame Work to 3.2.0 or above!
I think You are using Spring 3.0.5 and you need to use Spring 4.0.* This will resolve your problem.
org.springframework.web.bind.annotation.RequestMapping is not available in Spring-web earlier then Spring-web 4.0.*
Sometimes there is some error in the local Maven repo. So please close your eclipse and delete the jar spring-webmvc from your local .m2 then open Eclipse and on the project press
Update Maven Dependencies.
Then Eclipse will download the dependency again for you.
That how I fixed the same problem.
I was using spring-web version 4.3.7
Changing it to a working 4.1.7 immediately solved it.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I had the same problem but I solved in other way (becouse at right click on project folder no Maven tab apears only if I do that on pom.xml I can see a Maven tab):
So I tink that you get that error because the IDE (Eclipse) didn`t import the dependecies from Maven. Since you are using Spring framework and you probably have STS allready installed right-click on project folder Spring Tools -> Update Maven Dependecies.
I`m using
Eclipse JUNO
m2eclipse 1.3.0
Spring IDEE 3.1
Go to pom.xml
Add this Dependency :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
using command prompt, find your folder:
- mvn clean
I had almost the same problem but it was just because some .jar library wasn't updated.
I couldn't use #RequestMapping cause that, just "mouse over #RequestMapping" and click on "Fix ..." and the .jar library will be downloading and installing.
-> Go to pom.xml
-> Add this Dependency :
-> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
->Wait for Rebuild or manually rebuild the project
->if Maven is not auto build in your machine then manually follow below points to rebuild
right click on your project structure->Maven->Update Project->check "force update of snapshots/Releases"
Add this below dependency in your pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
This is used for #RestController, #RequestMapping
Thanks above all of you contributions! however for my case I finally realized that my dependency above "spring-web" was destroyed on my .m2/repository/org/springframework/spring-web, I just deleted the folder and update Maven again. it got fixed.
Step 1 - The problem is with Eclipse IDE
Step 2 - Right Click Maven Dependencies -> Build Path -> Remove Build Path
Update pom.xml for spring-web and spring-webmvc
Step 3 - Update Maven Dependencies
You will see the Spring-Web files will be in the maven dependencies folder.

Resources