Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. 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: {}
  2.  
  3. @Configuration
  4. @Profile("development")
  5. @EnableTransactionManagement
  6. public class DatabaseConfig {
  7.  
  8.  
  9.  
  10. @Bean(name = "datasource")
  11. public DriverManagerDataSource dataSource() {
  12. DriverManagerDataSource dataSource = new DriverManagerDataSource();
  13. dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  14. dataSource.setUrl("jdbc:mysql://localhost:3306/codeals");
  15. dataSource.setUsername("root");
  16. dataSource.setPassword("root");
  17. return dataSource;
  18. }
  19.  
  20. @Bean(name = "namingStrategy")
  21. public ImprovedNamingStrategy getNamingStrategy(){
  22.  
  23. ImprovedNamingStrategy namingStrategy = new CDCustomNamingStrategy();
  24. return namingStrategy;
  25. }
  26.  
  27. @Bean(name = "entityManagerFactory")
  28. public LocalContainerEntityManagerFactoryBean entityManagerFactory(DriverManagerDataSource dataSource, ImprovedNamingStrategy ins) {
  29.  
  30. LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
  31. entityManagerFactoryBean.setDataSource(dataSource);
  32. entityManagerFactoryBean.setPackagesToScan(new String[]{"com.covenant.app.model"});
  33. entityManagerFactoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
  34. entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
  35.  
  36.  
  37. Map<String, Object> jpaProperties = new HashMap<String, Object>();
  38. jpaProperties.put("hibernate.hbm2ddl.auto", "update");
  39. jpaProperties.put("hibernate.show_sql", "true");
  40. jpaProperties.put("hibernate.format_sql", "true");
  41. jpaProperties.put("hibernate.use_sql_comments", "true");
  42. jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
  43. jpaProperties.put("hibernate.ejb.naming_strategy", ins);
  44. entityManagerFactoryBean.setJpaPropertyMap(jpaProperties);
  45.  
  46. return entityManagerFactoryBean;
  47. }
  48.  
  49. }
  50.  
  51. ---
  52. applications:
  53. - name: lordthankyou
  54. path: target/ideals.war
  55. services:
  56. - mysql
  57. env:
  58. SPRING_PROFILES_ACTIVE: development
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement