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
05ef0818
Commit
05ef0818
authored
Apr 05, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish contribution
Closes gh-5511
parent
6a2ff3f0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
7 deletions
+51
-7
HealthIndicatorAutoConfigurationTests.java
.../autoconfigure/HealthIndicatorAutoConfigurationTests.java
+2
-0
ElasticsearchAutoConfiguration.java
...re/data/elasticsearch/ElasticsearchAutoConfiguration.java
+1
-2
ElasticsearchAutoConfigurationTests.java
...ta/elasticsearch/ElasticsearchAutoConfigurationTests.java
+5
-2
ElasticsearchRepositoriesAutoConfigurationTests.java
...arch/ElasticsearchRepositoriesAutoConfigurationTests.java
+9
-0
pom.xml
spring-boot-dependencies/pom.xml
+6
-0
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+16
-3
pom.xml
...oot-samples/spring-boot-sample-data-elasticsearch/pom.xml
+7
-0
application.properties
...a-elasticsearch/src/main/resources/application.properties
+5
-0
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java
View file @
05ef0818
...
...
@@ -393,6 +393,7 @@ public class HealthIndicatorAutoConfigurationTests {
@Test
public
void
elasticSearchHealthIndicator
()
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.elasticsearch.properties.path.home:target"
,
"management.health.diskspace.enabled:false"
);
this
.
context
.
register
(
ElasticsearchAutoConfiguration
.
class
,
ManagementServerProperties
.
class
,
HealthIndicatorAutoConfiguration
.
class
);
...
...
@@ -409,6 +410,7 @@ public class HealthIndicatorAutoConfigurationTests {
public
void
notElasticSearchHealthIndicator
()
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"management.health.elasticsearch.enabled:false"
,
"spring.data.elasticsearch.properties.path.home:target"
,
"management.health.diskspace.enabled:false"
);
this
.
context
.
register
(
ElasticsearchAutoConfiguration
.
class
,
ManagementServerProperties
.
class
,
HealthIndicatorAutoConfiguration
.
class
);
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.java
View file @
05ef0818
...
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
elasticsearch
;
import
java.io.File
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
...
...
@@ -63,7 +62,7 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
Map
<
String
,
String
>
defaults
=
new
LinkedHashMap
<
String
,
String
>();
defaults
.
put
(
"http.enabled"
,
String
.
valueOf
(
false
));
defaults
.
put
(
"node.local"
,
String
.
valueOf
(
true
));
defaults
.
put
(
"path.home"
,
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
),
"elastic-home"
).
getAbsolutePath
(
));
defaults
.
put
(
"path.home"
,
System
.
getProperty
(
"user.dir"
));
DEFAULTS
=
Collections
.
unmodifiableMap
(
defaults
);
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfigurationTests.java
View file @
05ef0818
...
...
@@ -56,7 +56,8 @@ public class ElasticsearchAutoConfigurationTests {
public
void
createNodeClientWithDefaults
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.elasticsearch.properties.foo.bar:baz"
);
"spring.data.elasticsearch.properties.foo.bar:baz"
,
"spring.data.elasticsearch.properties.path.home:target"
);
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
);
this
.
context
.
refresh
();
...
...
@@ -72,6 +73,7 @@ public class ElasticsearchAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.elasticsearch.properties.foo.bar:baz"
,
"spring.data.elasticsearch.properties.path.home:target"
,
"spring.data.elasticsearch.properties.node.local:false"
,
"spring.data.elasticsearch.properties.node.data:true"
,
"spring.data.elasticsearch.properties.http.enabled:true"
);
...
...
@@ -104,7 +106,8 @@ public class ElasticsearchAutoConfigurationTests {
// a port and check the exception
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.elasticsearch.cluster-nodes:localhost"
);
"spring.data.elasticsearch.cluster-nodes:localhost"
,
"spring.data.elasticsearch.properties.path.home:target"
);
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
);
this
.
thrown
.
expect
(
BeanCreationException
.
class
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfigurationTests.java
View file @
05ef0818
...
...
@@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElastic
import
org.springframework.boot.autoconfigure.data.elasticsearch.city.City
;
import
org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository
;
import
org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories
;
...
...
@@ -49,6 +50,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
public
void
testDefaultRepositoryConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
addElasticsearchProperties
(
this
.
context
);
this
.
context
.
register
(
TestConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
...
...
@@ -62,6 +64,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
public
void
testNoRepositoryConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
addElasticsearchProperties
(
this
.
context
);
this
.
context
.
register
(
EmptyConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
...
...
@@ -74,6 +77,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
@Test
public
void
doesNotTriggerDefaultRepositoryDetectionIfCustomized
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
addElasticsearchProperties
(
this
.
context
);
this
.
context
.
register
(
CustomizedConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
,
ElasticsearchRepositoriesAutoConfiguration
.
class
,
...
...
@@ -83,6 +87,11 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
assertThat
(
this
.
context
.
getBean
(
CityElasticsearchDbRepository
.
class
)).
isNotNull
();
}
private
void
addElasticsearchProperties
(
AnnotationConfigApplicationContext
context
)
{
EnvironmentTestUtils
.
addEnvironment
(
context
,
"spring.data.elasticsearch.properties.path.home:target"
);
}
@Configuration
@TestAutoConfigurationPackage
(
City
.
class
)
protected
static
class
TestConfiguration
{
...
...
spring-boot-dependencies/pom.xml
View file @
05ef0818
...
...
@@ -105,6 +105,7 @@
<jetty.version>
9.2.15.v20160210
</jetty.version>
<jetty-jsp.version>
2.2.0.v201112011158
</jetty-jsp.version>
<jmustache.version>
1.12
</jmustache.version>
<jna.version>
4.2.2
</jna.version>
<joda-time.version>
2.9.2
</joda-time.version>
<jolokia.version>
1.3.3
</jolokia.version>
<jooq.version>
3.7.2
</jooq.version>
...
...
@@ -951,6 +952,11 @@
<artifactId>
mysql-connector-java
</artifactId>
<version>
${mysql.version}
</version>
</dependency>
<dependency>
<groupId>
net.java.dev.jna
</groupId>
<artifactId>
jna
</artifactId>
<version>
${jna.version}
</version>
</dependency>
<dependency>
<groupId>
net.sf.ehcache
</groupId>
<artifactId>
ehcache
</artifactId>
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
05ef0818
...
...
@@ -3214,11 +3214,24 @@ dependencies in a convenient way.
[[boot-features-connecting-to-elasticsearch]]
==== Connecting to Elasticsearch
You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Client`
instance as you would any other Spring Bean. By default the instance will attempt to
connect to a local in-memory server (a `NodeClient` in Elasticsearch terms), but you can
switch to a remote server (i.e. a `TransportClient`) by setting
instance as you would any other Spring Bean. By default the instance will embed a
local in-memory server (a `Node` in ElasticSearch terms) and use the current working
directory as the home directory for the server. In this setup, the first thing to do
is to tell ElasticSearch were to store its files:
[source,properties,indent=0]
----
spring.data.elasticsearch.properties.path.home=/foo/bar
----
Alternatively, you can switch to a remote server (i.e. a `TransportClient`) by setting
`spring.data.elasticsearch.cluster-nodes` to a comma-separated '`host:port`' list.
[source,properties,indent=0]
----
spring.data.elasticsearch.cluster-nodes=localhost:9300
----
[source,java,indent=0]
----
@Component
...
...
spring-boot-samples/spring-boot-sample-data-elasticsearch/pom.xml
View file @
05ef0818
...
...
@@ -26,6 +26,13 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-elasticsearch
</artifactId>
</dependency>
<dependency>
<groupId>
net.java.dev.jna
</groupId>
<artifactId>
jna
</artifactId>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
spring-boot-samples/spring-boot-sample-data-elasticsearch/src/main/resources/application.properties
0 → 100644
View file @
05ef0818
#
# Home directory of the embedded elastic instance. Default to the
# current working directory.
#
spring.data.elasticsearch.properties.path.home
=
target/elastic
\ No newline at end of file
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