File tree 6 files changed +30
-35
lines changed
spring-data-elasticsearch
java/com/baeldung/spring/data/es
test/java/com/baeldung/spring/data/es
6 files changed +30
-35
lines changed Original file line number Diff line number Diff line change 11
11
12
12
<properties >
13
13
<project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
14
+ <maven .compiler.source>1.8</maven .compiler.source>
15
+ <maven .compiler.target>1.8</maven .compiler.target>
14
16
15
- <org .springframework.data.version>1.3.2.RELEASE</org .springframework.data.version>
16
17
<org .springframework.version>4.2.5.RELEASE</org .springframework.version>
17
18
18
19
<junit .version>4.11</junit .version>
27
28
<artifactId >spring-core</artifactId >
28
29
<version >${org.springframework.version} </version >
29
30
</dependency >
31
+ <dependency >
32
+ <groupId >org.springframework.data</groupId >
33
+ <artifactId >spring-data-elasticsearch</artifactId >
34
+ <version >${elasticsearch.version} </version >
35
+ </dependency >
36
+
30
37
<dependency >
31
38
<groupId >junit</groupId >
32
39
<artifactId >junit-dep</artifactId >
39
46
<version >${org.springframework.version} </version >
40
47
<scope >test</scope >
41
48
</dependency >
42
- <dependency >
43
- <groupId >org.springframework.data</groupId >
44
- <artifactId >spring-data-elasticsearch</artifactId >
45
- <version >${elasticsearch.version} </version >
46
- </dependency >
47
- <dependency > <groupId >net.java.dev.jna</groupId >
49
+ <dependency >
50
+ <groupId >net.java.dev.jna</groupId >
48
51
<artifactId >jna</artifactId >
49
52
<version >4.1.0</version >
50
53
<scope >test</scope >
51
54
</dependency >
55
+
52
56
<dependency >
53
57
<groupId >org.slf4j</groupId >
54
58
<artifactId >slf4j-api</artifactId >
81
85
<version >1.2.13</version >
82
86
</dependency >
83
87
</dependencies >
84
- <build >
85
- <plugins >
86
- <plugin >
87
- <artifactId >maven-compiler-plugin</artifactId >
88
- <version >2.3.2</version >
89
- <configuration >
90
- <source >1.8</source >
91
- <target >1.8</target >
92
- </configuration >
93
- </plugin >
94
- </plugins >
95
- </build >
96
- </project >
88
+
89
+ </project >
Original file line number Diff line number Diff line change @@ -32,18 +32,22 @@ public class Config {
32
32
public Client client () {
33
33
try {
34
34
final Path tmpDir = Files .createTempDirectory (Paths .get (System .getProperty ("java.io.tmpdir" )), "elasticsearch_data" );
35
-
35
+ logger .debug (tmpDir .toAbsolutePath ().toString ());
36
+
36
37
// @formatter:off
37
38
38
39
final Settings .Builder elasticsearchSettings =
39
40
Settings .settingsBuilder ().put ("http.enabled" , "false" )
40
41
.put ("path.data" , tmpDir .toAbsolutePath ().toString ())
41
42
.put ("path.home" , elasticsearchHome );
43
+
44
+ return new NodeBuilder ()
45
+ .local (true )
46
+ .settings (elasticsearchSettings )
47
+ .node ()
48
+ .client ();
49
+
42
50
// @formatter:on
43
-
44
- logger .debug (tmpDir .toAbsolutePath ().toString ());
45
-
46
- return new NodeBuilder ().local (true ).settings (elasticsearchSettings .build ()).node ().client ();
47
51
} catch (final IOException ioex ) {
48
52
logger .error ("Cannot create temp dir" , ioex );
49
53
throw new RuntimeException ();
Original file line number Diff line number Diff line change 10
10
@ Service
11
11
public class ArticleServiceImpl implements ArticleService {
12
12
13
- private ArticleRepository articleRepository ;
14
-
13
+ private final ArticleRepository articleRepository ;
14
+
15
15
@ Autowired
16
- public void setArticleRepository (ArticleRepository articleRepository ) {
16
+ public ArticleServiceImpl (ArticleRepository articleRepository ) {
17
17
this .articleRepository = articleRepository ;
18
18
}
19
19
Original file line number Diff line number Diff line change 8
8
</appender >
9
9
10
10
<logger name =" org.springframework" level =" WARN" />
11
- <logger name =" com.baeldung.config" level =" DEBUG" />
12
11
13
- <!-- in order to debug some marshalling issues, this needs to be TRACE -->
14
- <logger name =" org.springframework.web.servlet.mvc" level =" WARN" />
12
+ <!-- in order to debug some elastic issues, this needs to be DEBUG or INFO -->
13
+ <logger name =" org.elasticsearch" level =" INFO" />
14
+ <logger name =" com.baeldung.spring" level =" DEBUG" />
15
15
16
16
<root level =" INFO" >
17
17
<appender-ref ref =" STDOUT" />
Original file line number Diff line number Diff line change 34
34
import org .springframework .data .elasticsearch .core .query .SearchQuery ;
35
35
import org .springframework .test .context .ContextConfiguration ;
36
36
import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
37
- import org .springframework .test .context .support .AnnotationConfigContextLoader ;
38
37
39
38
import com .baeldung .spring .data .es .config .Config ;
40
39
import com .baeldung .spring .data .es .model .Article ;
41
40
import com .baeldung .spring .data .es .model .Author ;
42
41
import com .baeldung .spring .data .es .service .ArticleService ;
43
42
44
43
@ RunWith (SpringJUnit4ClassRunner .class )
45
- @ ContextConfiguration (classes = { Config . class }, loader = AnnotationConfigContextLoader .class )
44
+ @ ContextConfiguration (classes = Config .class )
46
45
public class ElasticSearchQueryTest {
47
46
48
47
@ Autowired
Original file line number Diff line number Diff line change 21
21
import org .springframework .data .elasticsearch .core .query .SearchQuery ;
22
22
import org .springframework .test .context .ContextConfiguration ;
23
23
import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
24
- import org .springframework .test .context .support .AnnotationConfigContextLoader ;
25
24
26
25
import com .baeldung .spring .data .es .config .Config ;
27
26
import com .baeldung .spring .data .es .model .Article ;
28
27
import com .baeldung .spring .data .es .model .Author ;
29
28
import com .baeldung .spring .data .es .service .ArticleService ;
30
29
31
30
@ RunWith (SpringJUnit4ClassRunner .class )
32
- @ ContextConfiguration (classes = { Config . class }, loader = AnnotationConfigContextLoader .class )
31
+ @ ContextConfiguration (classes = Config .class )
33
32
public class ElasticSearchTest {
34
33
35
34
@ Autowired
You can’t perform that action at this time.
0 commit comments