Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Error creating bean with name 'entityManagerFactory' defined in com.covenant.app.config.root.DatabaseConfig: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.jdbc.datasource.DriverManagerDataSource]: : No qualifying bean of type [org.springframework.jdbc.datasource.DriverManagerDataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.jdbc.datasource.DriverManagerDataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
- @Configuration
- @Profile("development")
- @EnableTransactionManagement
- public class DatabaseConfig {
- @Bean(name = "datasource")
- public DriverManagerDataSource dataSource() {
- DriverManagerDataSource dataSource = new DriverManagerDataSource();
- dataSource.setDriverClassName("com.mysql.jdbc.Driver");
- dataSource.setUrl("jdbc:mysql://localhost:3306/codeals");
- dataSource.setUsername("root");
- dataSource.setPassword("root");
- return dataSource;
- }
- @Bean(name = "namingStrategy")
- public ImprovedNamingStrategy getNamingStrategy(){
- ImprovedNamingStrategy namingStrategy = new CDCustomNamingStrategy();
- return namingStrategy;
- }
- @Bean(name = "entityManagerFactory")
- public LocalContainerEntityManagerFactoryBean entityManagerFactory(DriverManagerDataSource dataSource, ImprovedNamingStrategy ins) {
- LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
- entityManagerFactoryBean.setDataSource(dataSource);
- entityManagerFactoryBean.setPackagesToScan(new String[]{"com.covenant.app.model"});
- entityManagerFactoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
- entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
- Map<String, Object> jpaProperties = new HashMap<String, Object>();
- jpaProperties.put("hibernate.hbm2ddl.auto", "update");
- jpaProperties.put("hibernate.show_sql", "true");
- jpaProperties.put("hibernate.format_sql", "true");
- jpaProperties.put("hibernate.use_sql_comments", "true");
- jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
- jpaProperties.put("hibernate.ejb.naming_strategy", ins);
- entityManagerFactoryBean.setJpaPropertyMap(jpaProperties);
- return entityManagerFactoryBean;
- }
- }
- ---
- applications:
- - name: lordthankyou
- path: target/ideals.war
- services:
- - mysql
- env:
- SPRING_PROFILES_ACTIVE: development
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement