Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled

Ask Question

My Autoconfiguration file is not working in Spring-Boot application. I attach my configuration application file below:

@Configuration
@EnableAutoConfiguration
@ComponentScan
@SpringBootApplication
@EnableScheduling
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);

Thrown Exception is below. How can I fix it?

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-01-19 14:50:06.085 ERROR 7614 --- [           main] o.s.boot.SpringApplication               : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; 
nested exception is java.lang.NoClassDefFoundError: org/hibernate/boot/archive/scan/spi/ScanEnvironment
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1589) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:554) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBectBeanFactory.java:302) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at com.track.io.Application.main(Application.java:35) [classes/:na]
                \@Configuration \@EnableAutoConfiguration \@ComponentScan are implied already due to the @SpringBootApplication annotation.
– Jared
                Oct 20, 2021 at 15:35
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.0.7.Final</version>
</dependency>

Remove JPA dependency if you are not using it.

    <!--   dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency -->

In my case i have included jdbc api dependencies in the project so the "Hello World" not printed. After removing the below dependency it works like a charm.

       <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>
                Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
– Community
                Oct 6, 2021 at 20:17

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>