Gradle in IntelliJ cannot find Spring JdbcTemplate - spring

I created spring rest API in IntelliJ IDEA using Gradle. When I am using the JDBCTemplate it is not imported in the project, and I get the following message:
package org.springframework.jdbc.core does not exist import org.springframework.jdbc.core.JdbcTemplate; in gradle intellij
Even though this jar file is showing in the external libraries.

Related

Converting existing project to Spring boot project in InelliJ

I have an existing project. I need to make it a Spring boot based project and I am using IntelliJ CE.
What would be correct procedure for doing it?
Edit:
Project has no initial structure. It is a totally empty project. So no existing modules etc.
Spring Boot is an Ultimate feature, so first you would need to try/buy the IntelliJ IDEA Ultimate.
From there, you can add Spring support to existing project modules or use the Spring Initializr wizard to select the necessary configuration when creating a new project or module.
In your maven pom.xml or build.gradle file, I would add the spring boot starter dependency:
spring-boot-starter (the group id is org.springframework.boot)
If the application is a web application, I would also add the web starter spring-boot-starter-web also with the same group id (org.springframework.boot)
For convenient features, applying the spring boot plugin would help in creating a runnable jar with all required dependencies bundled called a fat jar.
A great tool I use is the spring boot project generator. It allows you to configure the modules you want and create a project template.
Spring Boot requires IntelliJ IDEA Ultimate. If you want to use IntelliJ CE, please create a project using Spring Initilizer then import the same to your IntelliJ CE (File -> Open -> Choose the project root folder). After you import the project, wait for some time so that IntelliJ can download the dependency and build your project. You can check from (Build -> Build your project). Then find the main class of spring boot and run it using the green play button

can not resolve SpringBootApplication in springboot 1.5.4.release

I am learning spring boot now, so I download the demo generated by the auto generator in spring boot, but after I import this project into IDEA, something wrong happens, the IDEA can not resolve the SpringBootApplication annotation! So I can not even start the "hello world" with spring boot, can anyone encounter such problems?
I made a mistake while import spring.demo project, I should import it as a maven project so that its dependency can be resolved automatically, but what I have done is that I import it as creating a new project not a maven project , so its class can not be resolved automatically.

Spring boot framework fails to find MongoRepository if its from different package other than root package

I am building an application using Spring boot framework. Below are my package structure.
com.example.dal -> contains MongoRepositories
com.example.app -> web
application and contains main method to spring
application
The spring framework not able to find repositories if they are in 'com.example.dal' package. But works as expected if they are in 'com.example.app'. I tried different options like below
#ComponentScan("com.example.dal")
#EnableMongoRepositories(basePackages = {"com.example.dal"})
But none of them solves the issue.
Did any one face the same issue?
Or is it an issue with Spring framework ?

How To create RestClient with Spring Boot Application in Spring Tool Suite

I am new to STS. I am creating RESTful Web Services with the Jersey implementation using the Gradle Build tool. Can any one tell me how to create or consume REST in STS?
Spring Boot provides many sample projects on GitHub that can be used for getting started on a new project. In your case the Jersey sample project should provide you with a good starting point.
After download the sample source code you can import the project into STS using File -> Import and select Existing Maven Project.

conflicts in maven dependencies for sun jersey client

I have a large project having a number of maven modules under the root module datastore , In one of the modules I am using the jersey client dependencies as ,
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
This is the dependency which is to be used.
The Client was working fine.
Then, I copied the same code with same imports of jersey into other multi-module maven project and added the dependencies into pom XML.
But now the code crashes and I found out that the dependencies that are being referred now are different!!
So, I want to know:
How to explicitly specify which dependencies are to be used? (Note: I changed the pom of this new module but it is again getting jersey deps. from parent pom)
It seems like your project may have a different version of jersey libraries ,
Because there are a lot of changes in jersey 1.x and jersey 2.x APIs
So instead of getting multiple conflicting dependencies for the same lib , try to modify/upgrade your code to match jersey 2.0 API
Here is a guide for code migration

Resources