Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
93e6a717
Commit
93e6a717
authored
Jun 17, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3126 from eddumelendez/gh-3105
* gh-3105: Remove deprecated SimpleMongoDbFactory call
parents
73d5a858
4883a524
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
15 deletions
+9
-15
MongoAutoConfiguration.java
...work/boot/autoconfigure/mongo/MongoAutoConfiguration.java
+5
-5
MongoDataAutoConfiguration.java
.../boot/autoconfigure/mongo/MongoDataAutoConfiguration.java
+4
-10
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java
View file @
93e6a717
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -28,7 +28,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
...
@@ -28,7 +28,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
com.mongodb.Mongo
;
import
com.mongodb.Mongo
Client
;
import
com.mongodb.MongoClientOptions
;
import
com.mongodb.MongoClientOptions
;
/**
/**
...
@@ -39,7 +39,7 @@ import com.mongodb.MongoClientOptions;
...
@@ -39,7 +39,7 @@ import com.mongodb.MongoClientOptions;
* @author Phillip Webb
* @author Phillip Webb
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
(
Mongo
.
class
)
@ConditionalOnClass
(
Mongo
Client
.
class
)
@EnableConfigurationProperties
(
MongoProperties
.
class
)
@EnableConfigurationProperties
(
MongoProperties
.
class
)
@ConditionalOnMissingBean
(
type
=
"org.springframework.data.mongodb.MongoDbFactory"
)
@ConditionalOnMissingBean
(
type
=
"org.springframework.data.mongodb.MongoDbFactory"
)
public
class
MongoAutoConfiguration
{
public
class
MongoAutoConfiguration
{
...
@@ -50,7 +50,7 @@ public class MongoAutoConfiguration {
...
@@ -50,7 +50,7 @@ public class MongoAutoConfiguration {
@Autowired
(
required
=
false
)
@Autowired
(
required
=
false
)
private
MongoClientOptions
options
;
private
MongoClientOptions
options
;
private
Mongo
mongo
;
private
Mongo
Client
mongo
;
@PreDestroy
@PreDestroy
public
void
close
()
{
public
void
close
()
{
...
@@ -61,7 +61,7 @@ public class MongoAutoConfiguration {
...
@@ -61,7 +61,7 @@ public class MongoAutoConfiguration {
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
public
Mongo
mongo
()
throws
UnknownHostException
{
public
Mongo
Client
mongo
()
throws
UnknownHostException
{
this
.
mongo
=
this
.
properties
.
createMongoClient
(
this
.
options
);
this
.
mongo
=
this
.
properties
.
createMongoClient
(
this
.
options
);
return
this
.
mongo
;
return
this
.
mongo
;
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoDataAutoConfiguration.java
View file @
93e6a717
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -42,7 +42,6 @@ import org.springframework.core.type.filter.AnnotationTypeFilter;
...
@@ -42,7 +42,6 @@ import org.springframework.core.type.filter.AnnotationTypeFilter;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.support.PersistenceExceptionTranslator
;
import
org.springframework.dao.support.PersistenceExceptionTranslator
;
import
org.springframework.data.annotation.Persistent
;
import
org.springframework.data.annotation.Persistent
;
import
org.springframework.data.authentication.UserCredentials
;
import
org.springframework.data.mongodb.MongoDbFactory
;
import
org.springframework.data.mongodb.MongoDbFactory
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.SimpleMongoDbFactory
;
import
org.springframework.data.mongodb.core.SimpleMongoDbFactory
;
...
@@ -60,6 +59,7 @@ import org.springframework.util.StringUtils;
...
@@ -60,6 +59,7 @@ import org.springframework.util.StringUtils;
import
com.mongodb.DB
;
import
com.mongodb.DB
;
import
com.mongodb.Mongo
;
import
com.mongodb.Mongo
;
import
com.mongodb.MongoClient
;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's mongo support.
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's mongo support.
...
@@ -74,6 +74,7 @@ import com.mongodb.Mongo;
...
@@ -74,6 +74,7 @@ import com.mongodb.Mongo;
* @author Oliver Gierke
* @author Oliver Gierke
* @author Josh Long
* @author Josh Long
* @author Phillip Webb
* @author Phillip Webb
* @author Eddú Meléndez
* @since 1.1.0
* @since 1.1.0
*/
*/
@Configuration
@Configuration
...
@@ -100,15 +101,8 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
...
@@ -100,15 +101,8 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
public
MongoDbFactory
mongoDbFactory
(
Mongo
mongo
)
throws
Exception
{
public
MongoDbFactory
mongoDbFactory
(
Mongo
Client
mongo
)
throws
Exception
{
String
database
=
this
.
properties
.
getMongoClientDatabase
();
String
database
=
this
.
properties
.
getMongoClientDatabase
();
String
authDatabase
=
this
.
properties
.
getAuthenticationDatabase
();
if
(
StringUtils
.
hasLength
(
authDatabase
))
{
String
username
=
this
.
properties
.
getUsername
();
String
password
=
new
String
(
this
.
properties
.
getPassword
());
UserCredentials
credentials
=
new
UserCredentials
(
username
,
password
);
return
new
SimpleMongoDbFactory
(
mongo
,
database
,
credentials
,
authDatabase
);
}
return
new
SimpleMongoDbFactory
(
mongo
,
database
);
return
new
SimpleMongoDbFactory
(
mongo
,
database
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment