package org.springframework.data.jpa does not exist using maven and IntelliJ - spring-boot

I have been having a problem with downloading a dependency for my spring boot project.
What have I tried:
I have tried adding this
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
to my pom.xml file. I have also tried looking up the dependency in IntelliJ to no avail. I need this so I can import org.springframework.data.jparepository to work thanks in advance.

Related

multiple annotations found at this line in pom.xml

Multiple annotations found at this line in pom.xml after adding below dependency to the pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
i wanted to write some test case for my spring boot application. I just tried adding "spring-boot-starter-test" artifactid to the pom.xml
Dependent jar files not updated properly to the project causing this issue, just check the below option to resolve.
Right Click the project -> Maven -> Update Project -> Force Update of Snapshots/Releases -> Ok
enter image description here

Imported Git Repository but some imports are not found?

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.

How to include custom type converter using Maven and Grails

I am working on a Grails project that needs to compile with both Grails and Maven. Everything worked great except for my GSON converter I added (using the grails-gson plugin). Now I get the following when I run mvn install.
unable to resolve class grails.plugin.gson.converters.GSON
Anyone know how to overcome this
Plugin has to be added as a dependency in pom.xml too
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>gson</artifactId>
<version>1.1.4</version>
<type>zip</type>
</dependency>
Mavenized grails project refer pom file for all dependencies (including plugin dependencies).

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