Advertisement
Guest User

Untitled

a guest
Aug 16th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.72 KB | None | 0 0
  1. #datasource
  2. spring.datasource.username=test
  3. spring.datasource.url=jdbc:mysql://localhost:3306/user_table
  4. spring.datasource.password=test
  5. spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  6.  
  7.  
  8. ##secondary Datasource
  9. #spring.sec.datasource.username=test
  10. #spring.sec.datasource.url=jdbc:mysql://localhost:3306/comp_table
  11. #spring.sec.datasource.password=test
  12. #spring.sec.datasource.driver-class-name=com.mysql.jdbc.Driver
  13.  
  14. #secondary Datasource
  15. spring.sec.datasource.url=jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
  16. spring.sec.datasource.driverClassName=org.h2.Driver
  17. spring.sec.datasource.username=sa
  18. spring.sec.datasource.password=
  19. spring.sec.jpa.database-platform=org.hibernate.dialect.H2Dialect
  20.  
  21. @Configuration
  22. public class DBConfig {
  23.  
  24.  
  25. @Bean(name="priDataSource")
  26. @Primary
  27. @ConfigurationProperties(prefix="spring.datasource")
  28. public DataSource priDataSource() {
  29. return DataSourceBuilder.create().build();
  30. }
  31.  
  32.  
  33. @Bean(name = "secDataSource")
  34. @ConfigurationProperties(prefix="spring.sec.datasource")
  35. public DataSource secDataSource() {
  36. return DataSourceBuilder.create().build();
  37. }
  38.  
  39. @Bean(name = "jdbcPriTemplate")
  40. @Autowired
  41. public JdbcTemplate jdbcPriTemplate(@Qualifier("priDataSource") DataSource hostds) {
  42. return new JdbcTemplate(hostds);
  43. }
  44.  
  45. @Bean(name = "jdbcSecTemplate")
  46. @Autowired
  47. public JdbcTemplate jdbcSecTemplate(@Qualifier("secDataSource") DataSource secDataSource) {
  48. return new JdbcTemplate(secDataSource);
  49. }
  50.  
  51. }
  52.  
  53. @SpringBootApplication
  54. public class Application {
  55.  
  56. public static void main(String[] args) {
  57. SpringApplication.run(Application.class, args);
  58. }
  59. }
  60.  
  61. 2016-08-16 15:37:28.186 WARN 22600 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: 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 javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
  62. 2016-08-16 15:37:28.192 INFO 22600 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
  63. 2016-08-16 15:37:28.212 INFO 22600 --- [ main] utoConfigurationReportLoggingInitializer :
  64.  
  65. Error starting ApplicationContext. To display the auto-configuration report enable debug logging (start with --debug)
  66.  
  67.  
  68. 2016-08-16 15:37:28.240 ERROR 22600 --- [ main] o.s.boot.SpringApplication : Application startup failed
  69.  
  70. 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 javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
  71. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  72. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  73. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  74. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  75. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  76. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  77. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  78. at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  79. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  80. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  81. at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
  82. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
  83. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
  84. at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
  85. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
  86. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
  87. at com.company.foo.Application.main(Application.java:10) [classes!/:na]
  88. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
  89. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
  90. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
  91. at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
  92. at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [sample-proj-1.0.0-SNAPSHOT.jar:na]
  93. at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [sample-proj-1.0.0-SNAPSHOT.jar:na]
  94. at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [sample-proj-1.0.0-SNAPSHOT.jar:na]
  95. at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [sample-proj-1.0.0-SNAPSHOT.jar:na]
  96. Caused by: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
  97. at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:603) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  98. at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:443) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  99. at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:424) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  100. at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:310) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  101. at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  102. at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  103. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  104. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  105. ... 24 common frames omitted
  106. Caused by: java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
  107. at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187) ~[spring-core-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  108. at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:600) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
  109. ... 31 common frames omitted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement