<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
"Error starting ApplicationContext" error
I even looked everywhere for solution nothing worked not even the above solutions, so I decided to read my errors 1 by 1 and found that there is another error at the end which is:
"No Property Found for Type" error
Then I found out that according to Spring Data JPA - Reference Documentation
, Naming matters in spring, So it goes like
For repositories:
It should be named as "___Repository"
For example:
UserRepository , OrderRepository, ContactRepository
For implementations:
It should be named as "___Impl"
For example:
ContactImpl, UserServiceImpl, OrderServiceImpl
Tip 1: All repository classes/interfaces should be placed in one directory
Tip 2: All service classes/interfaces should be placed in one directory
Tip 3: If your repository is named as UserRepository, the implementation of your repository should be named as UserRepositoryImpl
Tip 4: If your service interface is named as UserService, the implementation of your service interface should be named as UserServiceImpl
For more tips read the documentation.
It seems to me that your Hibernate libraries are not found (NoClassDefFoundError: org/hibernate/boot/archive/scan/spi/ScanEnvironment
as you can see above).
Try checking to see if Hibernate core is put in as dependency:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.11.Final</version>
<scope>compile</scope>
</dependency>
–
I came across the same error
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-21 22:57:45.237 ERROR 4952 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in com.sts.dao.UserRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: No property findbyName found for type User!
Because I defined wrong name for Custom Methods( or Derived methods) in My Repository while using Spring Data JPA, then I search Spring data Jpa reference where I found that there is strict naming convention for Custom methods which we need to follow otherwise it gives errors.
like findByName(), findInAge() , findByAgeLessThan()
In my case i was writing method like
**public List<User> findbyName(String name);**
which produced above error.
Suggestion: While working with spring data JPA follow camelCase and all naming convention defined in reference doc strictly to avoid errors.
I had the same error. My fix was to add "@Component" to the top of my class declaration. In your case it would be:
@Component
public class Application {
public static void main(String[] args) {
SpringApplication springApplication=new SpringApplication(Application.class);
System.out.println("Spring Core Version:- " + SpringVersion.getVersion());
springApplication.run(args);
with Spring boot version 3.0.3 :
I solved it by removing JPA dependency Starter ( i dont need it completly)
and I replaced it by spring-data-commons and spring-data-jpa
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>3.0.3</version>
</dependency> -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>3.0.2</version>
</dependency>