Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.26 KB | None | 0 0
  1. @ComponentScan
  2. @EnableAutoConfiguration
  3. @EnableHypermediaSupport
  4. @EnableSpringDataWebSupport
  5. public class ApplicationConfig {
  6.  
  7. @Bean
  8. public DataSource dataSource() {
  9. DriverManagerDataSource datasource = new DriverManagerDataSource();
  10. datasource.setDriverClassName("org.postgresql.Driver");
  11. datasource.setUrl("jdbc:postgresql://localhost/mydatabase");
  12. datasource.setUsername("myusername");
  13. datasource.setPassword("mypassword");
  14. return datasource;
  15. }
  16.  
  17. @Bean
  18. public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
  19. LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
  20. lef.setDataSource(dataSource);
  21. lef.setJpaVendorAdapter(jpaVendorAdapter);
  22. lef.setPackagesToScan("my.domain.package");
  23. Properties jpaProperties = new Properties();
  24. jpaProperties.setProperty("hibernate.hbm2ddl.auto", "update");
  25. lef.setJpaProperties(jpaProperties);
  26. return lef;
  27. }
  28.  
  29. @Bean
  30. public JpaVendorAdapter jpaVendorAdapter() {
  31. HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
  32. hibernateJpaVendorAdapter.setShowSql(false);
  33. hibernateJpaVendorAdapter.setGenerateDdl(true);
  34. hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL);
  35. return hibernateJpaVendorAdapter;
  36. }
  37.  
  38. @Bean
  39. public PlatformTransactionManager transactionManager() {
  40. return new JpaTransactionManager();
  41. }
  42.  
  43. public static void main(String[] args) {
  44. SpringApplication.run(ApplicationConfig.class, args);
  45. }
  46. }
  47.  
  48. 2014-02-23 18:17:30.735 INFO 27716 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@66e43eb8: startup date [Sun Feb 23 18:17:30 CET 2014]; root of context hierarchy
  49. 2014-02-23 18:17:31.354 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'pageableResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration; factoryMethodName=pageableResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration; factoryMethodName=pageableResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.class]]
  50. 2014-02-23 18:17:31.355 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'sortResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration; factoryMethodName=sortResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration; factoryMethodName=sortResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.class]]
  51. 2014-02-23 18:17:31.726 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'viewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=thymeleafConfig; factoryMethodName=viewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [be/**************/******/ThymeleafConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=viewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
  52. 2014-02-23 18:17:32.159 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'transactionManager': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=applicationConfig; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class **.**************.******.ApplicationConfig] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]]
  53. 2014-02-23 18:17:32.160 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'entityManagerFactory': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=applicationConfig; factoryMethodName=entityManagerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class **.**************.******.ApplicationConfig] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; factoryMethodName=entityManagerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]]
  54. 2014-02-23 18:17:32.160 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'jpaVendorAdapter': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=applicationConfig; factoryMethodName=jpaVendorAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class **.**************.******.ApplicationConfig] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; factoryMethodName=jpaVendorAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]]
  55. 2014-02-23 18:17:33.031 INFO 27716 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerByCGLIB$$9ca466b9] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  56. 2014-02-23 18:17:33.074 INFO 27716 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  57. 2014-02-23 18:17:33.092 INFO 27716 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  58. 2014-02-23 18:17:33.102 INFO 27716 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  59. 2014-02-23 18:17:33.779 INFO 27716 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
  60. 2014-02-23 18:17:33.779 INFO 27716 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.42
  61. 2014-02-23 18:17:33.909 INFO 27716 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  62. 2014-02-23 18:17:33.909 INFO 27716 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3177 ms
  63. 2014-02-23 18:17:35.028 INFO 27716 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
  64. 2014-02-23 18:17:35.028 INFO 27716 --- [ost-startStop-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
  65. 2014-02-23 18:17:35.124 INFO 27716 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  66. 2014-02-23 18:17:35.385 INFO 27716 --- [ost-startStop-1] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: org.postgresql.Driver
  67. 2014-02-23 18:17:35.457 INFO 27716 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
  68. 2014-02-23 18:17:35.592 INFO 27716 --- [ost-startStop-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
  69. 2014-02-23 18:17:35.622 INFO 27716 --- [ost-startStop-1] org.hibernate.Version : HHH000412: Hibernate Core {4.2.1.Final}
  70. 2014-02-23 18:17:35.627 INFO 27716 --- [ost-startStop-1] org.hibernate.cfg.Environment : HHH000205: Loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false, hibernate.hbm2ddl.auto=validate}
  71. 2014-02-23 18:17:35.628 INFO 27716 --- [ost-startStop-1] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
  72. 2014-02-23 18:17:35.655 INFO 27716 --- [ost-startStop-1] org.hibernate.ejb.Ejb3Configuration : HHH000204: Processing PersistenceUnitInfo [
  73. name: default
  74. ...]
  75. 2014-02-23 18:17:35.899 INFO 27716 --- [ost-startStop-1] o.h.s.j.c.i.ConnectionProviderInitiator : HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
  76. 2014-02-23 18:17:36.256 INFO 27716 --- [ost-startStop-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL82Dialect
  77. 2014-02-23 18:17:36.268 INFO 27716 --- [ost-startStop-1] o.h.e.jdbc.internal.LobCreatorBuilder : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
  78. 2014-02-23 18:17:36.284 INFO 27716 --- [ost-startStop-1] o.h.e.t.i.TransactionFactoryInitiator : HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
  79. 2014-02-23 18:17:36.292 INFO 27716 --- [ost-startStop-1] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
  80. 2014-02-23 18:17:36.481 INFO 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
  81. Hibernate: alter table project drop constraint FK_4725849e7c4543e3885bbd3a3a9
  82. 2014-02-23 18:17:36.488 ERROR 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table project drop constraint FK_4725849e7c4543e3885bbd3a3a9
  83. 2014-02-23 18:17:36.488 ERROR 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: constraint "fk_4725849e7c4543e3885bbd3a3a9" of relation "project" does not exist
  84. Hibernate: alter table project drop constraint FK_56d354acd26e412daa99d5584ff
  85. 2014-02-23 18:17:36.489 ERROR 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table project drop constraint FK_56d354acd26e412daa99d5584ff
  86. 2014-02-23 18:17:36.489 ERROR 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: constraint "fk_56d354acd26e412daa99d5584ff" of relation "project" does not exist
  87. Hibernate: drop table if exists company cascade
  88. Hibernate: drop table if exists project cascade
  89. Hibernate: create table company (id serial not null, name varchar(255), primary key (id))
  90. Hibernate: create table project (id serial not null, reference varchar(255), company int4, primary key (id))
  91. Hibernate: alter table project add constraint FK_4725849e7c4543e3885bbd3a3a9 foreign key (company) references company
  92. 2014-02-23 18:17:36.577 INFO 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
  93.  
  94. spring.jpa.database=POSTGRESQL
  95. spring.jpa.show-sql=false
  96. spring.jpa.hibernate.ddl-auto=update
  97.  
  98. spring.datasource.driver-class-name=org.postgresql.Driver
  99. spring.datasource.url=jdbc:postgresql://localhost/mydatabase
  100. spring.datasource.username=myusername
  101. spring.datasource.password=mypassword
  102.  
  103. spring:
  104. jpa:
  105. hibernate:
  106. ddl-auto: none
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement