Jak skonfigurować MongoDB w Springu?

0

Witam,

Co należy zrobić po dodaniu dependencji MongoDB w POMie, żeby skonfigurować tę bazę?

w application.properties dodałem:

spring.data.mongodb.uri=mongodb://localhost/

ale wywala mi błąd.

0

czy możesz być bardziej dokładny?
jaki to błąd?
poza tym, jak podajesz ip, to dobrze byłoby podać port na którym się łączysz

tutaj jest tutek: https://www.devglan.com/spring-boot/spring-boot-mongodb-configuration

0
trojanus napisał(a):

czy możesz być bardziej dokładny?
jaki to błąd?
poza tym, jak podajesz ip, to dobrze byłoby podać port na którym się łączysz

tutaj jest tutek: https://www.devglan.com/spring-boot/spring-boot-mongodb-configuration

Chyba MongoDB jest teraz ok.

Opis błędu:


APPLICATION FAILED TO START


Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

0
Commander300 napisał(a):
trojanus napisał(a):

czy możesz być bardziej dokładny?
jaki to błąd?
poza tym, jak podajesz ip, to dobrze byłoby podać port na którym się łączysz

tutaj jest tutek: https://www.devglan.com/spring-boot/spring-boot-mongodb-configuration

Chyba MongoDB jest teraz ok.

Opis błędu:


APPLICATION FAILED TO START


Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

czyli nie działa:

APPLICATION FAILED TO START

0

@Commander300: no to nie mam pojęcia. Jedyne co polecam sprawdzić to połączenie z mongo, czyli ustawienie 'url'. Albo możesz zrobić nowy projekt. Albo pokaż co masz w pom.xml, bo takto czaruję z fusów :P

0

Ja w pom nic nie dodawałem, jednak przy tworzeniu encji używałem adnotacji @Document, a w Spring Data moje repozytoria rozszerzały interfejs MongoRepository.

0

a nie url zamiast uri? ;)

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