Guest User

Untitled

a guest
Sep 18th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. package com.projetospringboot.meuprojeto.dao;
  2.  
  3. import org.springframework.context.annotation.Bean;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.jdbc.datasource.DriverManagerDataSource;
  6. import org.springframework.orm.jpa.JpaVendorAdapter;
  7. import org.springframework.orm.jpa.vendor.Database;
  8. import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
  9.  
  10. import javax.sql.DataSource;
  11.  
  12. @Configuration
  13. public class DataConfiguration {
  14.  
  15. @Bean
  16. public DataSource dataSource() {
  17. DriverManagerDataSource dataSource = new DriverManagerDataSource();
  18. dataSource.setDriverClassName("org.postgresql.Driver");
  19. dataSource.setUrl(""+
  20. "jdbc:postgresql://localhost:5432/BancoProjetoEventos");
  21. dataSource.setUsername("postgres");
  22. dataSource.setPassword("postgres");
  23. return dataSource;
  24. }
  25.  
  26. @Bean
  27. public JpaVendorAdapter jpaVendorAdapter() {
  28. HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
  29. adapter.setDatabase(Database.POSTGRESQL);
  30. adapter.setShowSql(true);
  31. adapter.setGenerateDdl(true);
  32. adapter.setDatabasePlatform(""+
  33. "org.hibernate.dialect.PostgreSQLDialect");
  34. adapter.setPrepareConnection(true);
  35. return adapter;
  36. }
  37. }
  38.  
  39. Error starting ApplicationContext. To display the conditions report re-run
  40. your application with 'debug' enabled.
  41. 2018-09-18 21:55:53.559 ERROR 2808 --- [ restartedMain]
  42. o.s.b.d.LoggingFailureAnalysisReporter :
  43.  
  44. ***************************
  45. APPLICATION FAILED TO START
  46. ***************************
  47.  
  48. Description:
  49.  
  50. Failed to configure a DataSource: 'url' attribute is not specified and no
  51. embedded datasource could be configured.
  52.  
  53. Reason: Failed to determine a suitable driver class
  54.  
  55.  
  56. Action:
  57.  
  58. Consider the following:
  59. If you want an embedded database (H2, HSQL or Derby), please put it on
  60. the classpath.
  61. If you have database settings to be loaded from a particular profile you
  62. may need to activate it (no profiles are currently active).
  63.  
  64.  
  65. Process finished with exit code 0
  66.  
  67. <?xml version="1.0" encoding="UTF-8"?>
  68. <project xmlns="http://maven.apache.org/POM/4.0.0"
  69. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  70. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  71. http://maven.apache.org/xsd/maven-4.0.0.xsd">
  72. <modelVersion>4.0.0</modelVersion>
  73.  
  74. <groupId>com.projeto-spring-boot</groupId>
  75. <artifactId>meu-projeto</artifactId>
  76. <version>0.0.1-SNAPSHOT</version>
  77. <packaging>jar</packaging>
  78.  
  79. <name>meu-projeto</name>
  80. <description>Demo project for Spring Boot</description>
  81.  
  82. <parent>
  83. <groupId>org.springframework.boot</groupId>
  84. <artifactId>spring-boot-starter-parent</artifactId>
  85. <version>2.0.5.RELEASE</version>
  86. <relativePath/> <!-- lookup parent from repository -->
  87. </parent>
  88.  
  89. <properties>
  90. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  91. <project.reporting.outputEncoding>
  92. UTF-8
  93. </project.reporting.outputEncoding>
  94. <java.version>1.8</java.version>
  95. </properties>
  96.  
  97. <dependencies>
  98. <dependency>
  99. <groupId>org.springframework.boot</groupId>
  100. <artifactId>spring-boot-starter-web</artifactId>
  101. </dependency>
  102. <dependency>
  103. <groupId>org.springframework.boot</groupId>
  104. <artifactId>spring-boot-devtools</artifactId>
  105. <scope>runtime</scope>
  106. </dependency>
  107. <dependency>
  108. <groupId>org.postgresql</groupId>
  109. <artifactId>postgresql</artifactId>
  110. <scope>runtime</scope>
  111. </dependency>
  112. <dependency>
  113. <groupId>org.springframework.boot</groupId>
  114. <artifactId>spring-boot-starter-data-jpa</artifactId>
  115. </dependency>
  116. <dependency>
  117. <groupId>org.springframework.boot</groupId>
  118. <artifactId>spring-boot-starter-test</artifactId>
  119. <scope>test</scope>
  120. </dependency>
  121. <dependency>
  122. <groupId>org.json</groupId>
  123. <artifactId>json</artifactId>
  124. <version>20090211</version>
  125. </dependency>
  126. </dependencies>
  127.  
  128. <build>
  129. <plugins>
  130. <plugin>
  131. <groupId>org.springframework.boot</groupId>
  132. <artifactId>spring-boot-maven-plugin</artifactId>
  133. </plugin>
  134. </plugins>
  135. </build>
  136. </project>
Add Comment
Please, Sign In to add comment