Java Spring Boot MongoDB Configuration












1















I am new and I try to develop an API with Java Spring Boot.
I have a problem with MongoDB Config and I have no problem in another project. I don't understand why.
I have already looked but the solutions proposed do not work.



SBApplication.java :



package basket;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication (scanBasePackages = { "basket.instrastructure.dao" })
@EnableSwagger2
@EnableAutoConfiguration //(exclude={MongoAutoConfiguration.class, MongoRepositoriesAutoConfiguration.class})
public class SBApplication {

public static void main(String args) {
SpringApplication.run(SBApplication.class, args);
}
}


BasketRepository.java :



package basket.infrastructure.dao;

import java.util.ArrayList;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import basket.domaine.model.Basket;

@Repository
public interface BasketRepository extends MongoRepository<Basket, Long> {

public ArrayList<Basket> findAll();
public Basket findById(String id);
}


ItemRepository.java :



package basket.infrastructure.dao;

import java.util.ArrayList;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import basket.domaine.model.Item;


@Repository
public interface ItemRepository extends MongoRepository<Item, Long> {
public Item findByName(String name);
public ArrayList<Item> findAll();
public Item findById(String id);
}


MongoConfig.java :



package basket.application.components;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoDatabase;

@Configuration
@EnableMongoRepositories ("basket.infrastructure.dao")
public class MongoConfig extends AbstractMongoConfiguration {

@Override
@Bean
public Mongo mongo() throws Exception {
MongoClientURI uri = new MongoClientURI("mongodb+srv://owner:AAAAA@basketcluster-feebu.mongodb.net/test?retryWrites=true");
MongoClient mongoClient = new MongoClient(uri);
MongoDatabase database = mongoClient.getDatabase("test");
return mongoClient;
}

@Override
protected String getDatabaseName() {
return "test";
}
}


And I have this error



com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.2.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_181]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_181]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_181]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.4.2.jar:na]
... 3 common frames omitted


Can you help me to understand my mistake.
Thank you, any help is very much appreciated!










share|improve this question























  • you forgot to add the port in your url

    – stacker
    Nov 19 '18 at 22:44
















1















I am new and I try to develop an API with Java Spring Boot.
I have a problem with MongoDB Config and I have no problem in another project. I don't understand why.
I have already looked but the solutions proposed do not work.



SBApplication.java :



package basket;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication (scanBasePackages = { "basket.instrastructure.dao" })
@EnableSwagger2
@EnableAutoConfiguration //(exclude={MongoAutoConfiguration.class, MongoRepositoriesAutoConfiguration.class})
public class SBApplication {

public static void main(String args) {
SpringApplication.run(SBApplication.class, args);
}
}


BasketRepository.java :



package basket.infrastructure.dao;

import java.util.ArrayList;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import basket.domaine.model.Basket;

@Repository
public interface BasketRepository extends MongoRepository<Basket, Long> {

public ArrayList<Basket> findAll();
public Basket findById(String id);
}


ItemRepository.java :



package basket.infrastructure.dao;

import java.util.ArrayList;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import basket.domaine.model.Item;


@Repository
public interface ItemRepository extends MongoRepository<Item, Long> {
public Item findByName(String name);
public ArrayList<Item> findAll();
public Item findById(String id);
}


MongoConfig.java :



package basket.application.components;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoDatabase;

@Configuration
@EnableMongoRepositories ("basket.infrastructure.dao")
public class MongoConfig extends AbstractMongoConfiguration {

@Override
@Bean
public Mongo mongo() throws Exception {
MongoClientURI uri = new MongoClientURI("mongodb+srv://owner:AAAAA@basketcluster-feebu.mongodb.net/test?retryWrites=true");
MongoClient mongoClient = new MongoClient(uri);
MongoDatabase database = mongoClient.getDatabase("test");
return mongoClient;
}

@Override
protected String getDatabaseName() {
return "test";
}
}


And I have this error



com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.2.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_181]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_181]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_181]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.4.2.jar:na]
... 3 common frames omitted


Can you help me to understand my mistake.
Thank you, any help is very much appreciated!










share|improve this question























  • you forgot to add the port in your url

    – stacker
    Nov 19 '18 at 22:44














1












1








1








I am new and I try to develop an API with Java Spring Boot.
I have a problem with MongoDB Config and I have no problem in another project. I don't understand why.
I have already looked but the solutions proposed do not work.



SBApplication.java :



package basket;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication (scanBasePackages = { "basket.instrastructure.dao" })
@EnableSwagger2
@EnableAutoConfiguration //(exclude={MongoAutoConfiguration.class, MongoRepositoriesAutoConfiguration.class})
public class SBApplication {

public static void main(String args) {
SpringApplication.run(SBApplication.class, args);
}
}


BasketRepository.java :



package basket.infrastructure.dao;

import java.util.ArrayList;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import basket.domaine.model.Basket;

@Repository
public interface BasketRepository extends MongoRepository<Basket, Long> {

public ArrayList<Basket> findAll();
public Basket findById(String id);
}


ItemRepository.java :



package basket.infrastructure.dao;

import java.util.ArrayList;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import basket.domaine.model.Item;


@Repository
public interface ItemRepository extends MongoRepository<Item, Long> {
public Item findByName(String name);
public ArrayList<Item> findAll();
public Item findById(String id);
}


MongoConfig.java :



package basket.application.components;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoDatabase;

@Configuration
@EnableMongoRepositories ("basket.infrastructure.dao")
public class MongoConfig extends AbstractMongoConfiguration {

@Override
@Bean
public Mongo mongo() throws Exception {
MongoClientURI uri = new MongoClientURI("mongodb+srv://owner:AAAAA@basketcluster-feebu.mongodb.net/test?retryWrites=true");
MongoClient mongoClient = new MongoClient(uri);
MongoDatabase database = mongoClient.getDatabase("test");
return mongoClient;
}

@Override
protected String getDatabaseName() {
return "test";
}
}


And I have this error



com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.2.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_181]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_181]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_181]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.4.2.jar:na]
... 3 common frames omitted


Can you help me to understand my mistake.
Thank you, any help is very much appreciated!










share|improve this question














I am new and I try to develop an API with Java Spring Boot.
I have a problem with MongoDB Config and I have no problem in another project. I don't understand why.
I have already looked but the solutions proposed do not work.



SBApplication.java :



package basket;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication (scanBasePackages = { "basket.instrastructure.dao" })
@EnableSwagger2
@EnableAutoConfiguration //(exclude={MongoAutoConfiguration.class, MongoRepositoriesAutoConfiguration.class})
public class SBApplication {

public static void main(String args) {
SpringApplication.run(SBApplication.class, args);
}
}


BasketRepository.java :



package basket.infrastructure.dao;

import java.util.ArrayList;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import basket.domaine.model.Basket;

@Repository
public interface BasketRepository extends MongoRepository<Basket, Long> {

public ArrayList<Basket> findAll();
public Basket findById(String id);
}


ItemRepository.java :



package basket.infrastructure.dao;

import java.util.ArrayList;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import basket.domaine.model.Item;


@Repository
public interface ItemRepository extends MongoRepository<Item, Long> {
public Item findByName(String name);
public ArrayList<Item> findAll();
public Item findById(String id);
}


MongoConfig.java :



package basket.application.components;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoDatabase;

@Configuration
@EnableMongoRepositories ("basket.infrastructure.dao")
public class MongoConfig extends AbstractMongoConfiguration {

@Override
@Bean
public Mongo mongo() throws Exception {
MongoClientURI uri = new MongoClientURI("mongodb+srv://owner:AAAAA@basketcluster-feebu.mongodb.net/test?retryWrites=true");
MongoClient mongoClient = new MongoClient(uri);
MongoDatabase database = mongoClient.getDatabase("test");
return mongoClient;
}

@Override
protected String getDatabaseName() {
return "test";
}
}


And I have this error



com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.2.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_181]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_181]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_181]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_181]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.4.2.jar:na]
... 3 common frames omitted


Can you help me to understand my mistake.
Thank you, any help is very much appreciated!







java spring mongodb maven spring-boot






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '18 at 22:28









DjypziDjypzi

61




61













  • you forgot to add the port in your url

    – stacker
    Nov 19 '18 at 22:44



















  • you forgot to add the port in your url

    – stacker
    Nov 19 '18 at 22:44

















you forgot to add the port in your url

– stacker
Nov 19 '18 at 22:44





you forgot to add the port in your url

– stacker
Nov 19 '18 at 22:44












1 Answer
1






active

oldest

votes


















0














Are you sure about your MongoDB URI? Usually, the URI has the form mongodb://localhost:27017/foo.



If you use Spring-boot instead of using a Configuration bean I suggest you use application.properties file. In this file write a property likes spring.data.mongodb.uri=mongodb://localhost:27017/foo and Spring-boot automatically injects the properties in MongoClient without any configuration at the code level.






share|improve this answer
























  • I will test with the application.porperties file I had a project in which I had no problem but I redid with DDD architecture. And now I have the problem. The database is on the server mongoDB. And in the doc I can connect to the data base with : MongoClientURI uri = new MongoClientURI( "mongodb+srv://kay:myRealPassword@cluster0.mongodb.net/"); MongoClient mongoClient = new MongoClient(uri); MongoDatabase database = mongoClient.getDatabase("test");

    – Djypzi
    Nov 21 '18 at 10:01













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383570%2fjava-spring-boot-mongodb-configuration%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Are you sure about your MongoDB URI? Usually, the URI has the form mongodb://localhost:27017/foo.



If you use Spring-boot instead of using a Configuration bean I suggest you use application.properties file. In this file write a property likes spring.data.mongodb.uri=mongodb://localhost:27017/foo and Spring-boot automatically injects the properties in MongoClient without any configuration at the code level.






share|improve this answer
























  • I will test with the application.porperties file I had a project in which I had no problem but I redid with DDD architecture. And now I have the problem. The database is on the server mongoDB. And in the doc I can connect to the data base with : MongoClientURI uri = new MongoClientURI( "mongodb+srv://kay:myRealPassword@cluster0.mongodb.net/"); MongoClient mongoClient = new MongoClient(uri); MongoDatabase database = mongoClient.getDatabase("test");

    – Djypzi
    Nov 21 '18 at 10:01


















0














Are you sure about your MongoDB URI? Usually, the URI has the form mongodb://localhost:27017/foo.



If you use Spring-boot instead of using a Configuration bean I suggest you use application.properties file. In this file write a property likes spring.data.mongodb.uri=mongodb://localhost:27017/foo and Spring-boot automatically injects the properties in MongoClient without any configuration at the code level.






share|improve this answer
























  • I will test with the application.porperties file I had a project in which I had no problem but I redid with DDD architecture. And now I have the problem. The database is on the server mongoDB. And in the doc I can connect to the data base with : MongoClientURI uri = new MongoClientURI( "mongodb+srv://kay:myRealPassword@cluster0.mongodb.net/"); MongoClient mongoClient = new MongoClient(uri); MongoDatabase database = mongoClient.getDatabase("test");

    – Djypzi
    Nov 21 '18 at 10:01
















0












0








0







Are you sure about your MongoDB URI? Usually, the URI has the form mongodb://localhost:27017/foo.



If you use Spring-boot instead of using a Configuration bean I suggest you use application.properties file. In this file write a property likes spring.data.mongodb.uri=mongodb://localhost:27017/foo and Spring-boot automatically injects the properties in MongoClient without any configuration at the code level.






share|improve this answer













Are you sure about your MongoDB URI? Usually, the URI has the form mongodb://localhost:27017/foo.



If you use Spring-boot instead of using a Configuration bean I suggest you use application.properties file. In this file write a property likes spring.data.mongodb.uri=mongodb://localhost:27017/foo and Spring-boot automatically injects the properties in MongoClient without any configuration at the code level.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 9:05









Federico GattiFederico Gatti

14212




14212













  • I will test with the application.porperties file I had a project in which I had no problem but I redid with DDD architecture. And now I have the problem. The database is on the server mongoDB. And in the doc I can connect to the data base with : MongoClientURI uri = new MongoClientURI( "mongodb+srv://kay:myRealPassword@cluster0.mongodb.net/"); MongoClient mongoClient = new MongoClient(uri); MongoDatabase database = mongoClient.getDatabase("test");

    – Djypzi
    Nov 21 '18 at 10:01





















  • I will test with the application.porperties file I had a project in which I had no problem but I redid with DDD architecture. And now I have the problem. The database is on the server mongoDB. And in the doc I can connect to the data base with : MongoClientURI uri = new MongoClientURI( "mongodb+srv://kay:myRealPassword@cluster0.mongodb.net/"); MongoClient mongoClient = new MongoClient(uri); MongoDatabase database = mongoClient.getDatabase("test");

    – Djypzi
    Nov 21 '18 at 10:01



















I will test with the application.porperties file I had a project in which I had no problem but I redid with DDD architecture. And now I have the problem. The database is on the server mongoDB. And in the doc I can connect to the data base with : MongoClientURI uri = new MongoClientURI( "mongodb+srv://kay:myRealPassword@cluster0.mongodb.net/"); MongoClient mongoClient = new MongoClient(uri); MongoDatabase database = mongoClient.getDatabase("test");

– Djypzi
Nov 21 '18 at 10:01







I will test with the application.porperties file I had a project in which I had no problem but I redid with DDD architecture. And now I have the problem. The database is on the server mongoDB. And in the doc I can connect to the data base with : MongoClientURI uri = new MongoClientURI( "mongodb+srv://kay:myRealPassword@cluster0.mongodb.net/"); MongoClient mongoClient = new MongoClient(uri); MongoDatabase database = mongoClient.getDatabase("test");

– Djypzi
Nov 21 '18 at 10:01




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383570%2fjava-spring-boot-mongodb-configuration%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?