Parameter 0 of constructor in org.springframework.data.jpa.repository.support.DefaultJpaContext required a bean of type 'java.util.Set' that could not be found.

See original GitHub issue

After migrating to SpringBoot 1.4.1, Spring Data Hopper-SR3 has updated and all projects are throwing the exception:

If I reduce the dependency to Hopper-SR2 it works fine again.

***************************
APPLICATION FAILED TO START
***************************
Description:

Parameter 0 of constructor in org.springframework.data.jpa.repository.support.DefaultJpaContext required a bean of type 'java.util.Set' that could not be found.

Action:
Consider defining a bean of type 'java.util.Set' in your configuration.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
Demoniancommented, Sep 29, 2016

The only solution that I found is to manually exclude JpaRepositoriesAutoConfiguration from spring boot and manually configure it:

@SpringBootApplication(scanBasePackages = {"test"} , exclude = JpaRepositoriesAutoConfiguration.class)
@EnableTransactionManagement
public class App extends SpringBootServletInitializer {
        public static void main(String[] args) {
            SpringApplication.run(App.class, args);
        }

        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(App.class);
        }
}
3reactions
IhorHryshkovcommented, Sep 29, 2016

Thank you Demonian, all good works if you configure next configuration DB class code:

@Configuration
public class DatabaseConfig {

    @Autowired
    private Environment env;


    @Bean
    public LocalSessionFactoryBean sessionFactory(DataSource dataSource) {
        LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
        sessionFactory.setDataSource(dataSource);
        sessionFactory.setPackagesToScan("{path to your database classes}");
        sessionFactory.setHibernateProperties(hibernateProperties());
        return sessionFactory;
    }

    public Properties hibernateProperties() {
        return new Properties() {
            {
                setProperty("hibernate.hbm2ddl.auto", env.getProperty("datasource.ddl-auto"));
                setProperty("hibernate.dialect", env.getProperty("datasource.hibernate.dialect"));
                setProperty("hibernate.show_sql", env.getProperty("datasource.show-sql"));
                setProperty("hibernate.format_sql", env.getProperty("datasource.format-sql"));
            }
        };
    }

    @Bean
    public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
        return new HibernateTransactionManager(sessionFactory);
    }

    @Bean
    public HibernateTemplate hibernateTemplate(SessionFactory sessionFactory) {
        return new HibernateTemplate(sessionFactory);
    }

}

And in YAML file write next data, example for postgres:

spring:
  datasource:
    url: jdbc:postgresql://{URL to postgres}:{postgres port}/{database name}
    username: {postgres username}
    password: {postgres password}
    driver-class-name: org.postgresql.Driver


logging:
  level:
    org.springframework: INFO
#    org.hibernate: DEBUG
    {main package path}: INFO

datasource:
  hibernate.dialect: org.hibernate.dialect.PostgreSQL95Dialect
  ddl-auto : none
  show-sql : false
  format-sql : true

And all good works!!! Thanks all. Regards.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating from Migrate to Spring MVC 4 + Hibernate5
Based on the spring boot error message, it fails to build the DefaultJpaContext bean whose constructor requires Set<javax.persistence.
Read more >
parameter 0 of constructor in required a bean of type 'java ...
parameter 0 of constructor in required a bean of type 'java.lang.string' that could not be found. @Qualifier annotation is needed to select exact...
Read more >
Parameter 0 Of Constructor In Required A Bean Of ... - ADocLib
import org.springframework.data.jpa.repository.config. ... is auto-wired as a bean type that could not be found in the spring boot context.
Read more >
spring-projects/spring-data - Gitter
BeanInstantiationException : Failed to instantiate [org.springframework.data.jpa.repository.support.DefaultJpaContext]: Constructor threw exception; ...
Read more >
the bean 'mvccontentnegotiationmanager' could not ... - You.com
Private Search. You are not the product, we'll never share your data ... is java.lang.AbstractMethodError at org.springframework.beans.factory.support.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found