Konfiguracja Hibernate/PostgreSql w SpringBoot

0

Witam,

Mógłby ktośporatować jakimś małym projektem skonfigurowanym w springboot z Hibernate i PostgreSql?
Ew. jeśli macie jakiś sensowny turorial to też może być, ale już próbowałęm i zawsze sypie jakieś błędy :/

0

Podaj kod i błędy :)

0

Link do git'a
https://github.com/HashTagDK/codeForum

**Treść konsoli po próbie kompilacji **

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.4.RELEASE)

2017-07-14 00:28:28.825  INFO 25687 --- [           main] com.hashtagdk.Application                : Starting Application on dawid-Lenovo-ideapad-700-15ISK with PID 25687 (/home/dawid/IdeaProjects/Projekt_codForum/codeForum/target/classes started by dawid in /home/dawid/IdeaProjects/Projekt_codForum/codeForum)
2017-07-14 00:28:28.827  INFO 25687 --- [           main] com.hashtagdk.Application                : No active profile set, falling back to default profiles: default
2017-07-14 00:28:29.008  INFO 25687 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2f0a87b3: startup date [Fri Jul 14 00:28:29 CEST 2017]; root of context hierarchy
2017-07-14 00:28:30.105  INFO 25687 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-14 00:28:30.112  INFO 25687 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-07-14 00:28:30.113  INFO 25687 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-07-14 00:28:30.172  INFO 25687 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-07-14 00:28:30.172  INFO 25687 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1167 ms
2017-07-14 00:28:30.256  INFO 25687 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-07-14 00:28:30.259  INFO 25687 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-07-14 00:28:30.259  INFO 25687 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-07-14 00:28:30.259  INFO 25687 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-07-14 00:28:30.259  INFO 25687 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-07-14 00:28:30.288  WARN 25687 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
2017-07-14 00:28:30.289  INFO 25687 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2017-07-14 00:28:30.301  INFO 25687 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-07-14 00:28:30.305 ERROR 25687 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).


Process finished with exit code 1
1

W *.properties chyba brakuje Ci tego : spring.datasource.driver-class-name=org.postgresql.Driver

0

Dodaj
@EnableJpaRepositories
W klasie Application.
Oraz w klasie User dodałem
@Table(name = "Inna_nazwa_niz_user_bo_user_jest_zakazana!")

I u mnie ruszyło

0

Tak jak napisał kolega wyżej. Nie możesz utworzyć tabeli w bazie danych o nazwie User, ponieważ ta nazwa jest zarezerwowana. Dlatego za pomocą adnotacji @Table i z parametrem name "powiesz" bazie danych, aby utworzyła tabele z zasugerowaną nazwą w ten adnotacji. Ten link pomoże Ci w konfiguracji bazy danych i innych parametrów w przyszłości.

1 użytkowników online, w tym zalogowanych: 0, gości: 1