some minor cleanup (#649)
* minor cleanup pom maven.compiler java versions as properties only specifing spring-data-elasticsearch as dependency formatting net.java.dev.jna dependency grouping main/test and logging dependencies removed unused org.springframework.data.version property * updated logback conf to this example * builder patttern code on multiple lines for readablilty * autowire via constructor into final variable as of spring-4.3 the @Autowired can be omitted \o/ jaj * @ContextConfiguration with less config
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
db2b93a1b6
commit
6c509ba738
@@ -32,18 +32,22 @@ public class Config {
|
||||
public Client client() {
|
||||
try {
|
||||
final Path tmpDir = Files.createTempDirectory(Paths.get(System.getProperty("java.io.tmpdir")), "elasticsearch_data");
|
||||
|
||||
logger.debug(tmpDir.toAbsolutePath().toString());
|
||||
|
||||
// @formatter:off
|
||||
|
||||
final Settings.Builder elasticsearchSettings =
|
||||
Settings.settingsBuilder().put("http.enabled", "false")
|
||||
.put("path.data", tmpDir.toAbsolutePath().toString())
|
||||
.put("path.home", elasticsearchHome);
|
||||
|
||||
return new NodeBuilder()
|
||||
.local(true)
|
||||
.settings(elasticsearchSettings)
|
||||
.node()
|
||||
.client();
|
||||
|
||||
// @formatter:on
|
||||
|
||||
logger.debug(tmpDir.toAbsolutePath().toString());
|
||||
|
||||
return new NodeBuilder().local(true).settings(elasticsearchSettings.build()).node().client();
|
||||
} catch (final IOException ioex) {
|
||||
logger.error("Cannot create temp dir", ioex);
|
||||
throw new RuntimeException();
|
||||
|
||||
@@ -10,10 +10,10 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ArticleServiceImpl implements ArticleService {
|
||||
|
||||
private ArticleRepository articleRepository;
|
||||
|
||||
private final ArticleRepository articleRepository;
|
||||
|
||||
@Autowired
|
||||
public void setArticleRepository(ArticleRepository articleRepository) {
|
||||
public ArticleServiceImpl(ArticleRepository articleRepository) {
|
||||
this.articleRepository = articleRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
</appender>
|
||||
|
||||
<logger name="org.springframework" level="WARN" />
|
||||
<logger name="com.baeldung.config" level="DEBUG" />
|
||||
|
||||
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
|
||||
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
|
||||
<!-- in order to debug some elastic issues, this needs to be DEBUG or INFO -->
|
||||
<logger name="org.elasticsearch" level="INFO" />
|
||||
<logger name="com.baeldung.spring" level="DEBUG" />
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
|
||||
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
import com.baeldung.spring.data.es.config.Config;
|
||||
import com.baeldung.spring.data.es.model.Article;
|
||||
@@ -42,7 +41,7 @@ import com.baeldung.spring.data.es.model.Author;
|
||||
import com.baeldung.spring.data.es.service.ArticleService;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Config.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = Config.class)
|
||||
public class ElasticSearchQueryTest {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
|
||||
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
import com.baeldung.spring.data.es.config.Config;
|
||||
import com.baeldung.spring.data.es.model.Article;
|
||||
@@ -29,7 +28,7 @@ import com.baeldung.spring.data.es.model.Author;
|
||||
import com.baeldung.spring.data.es.service.ArticleService;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Config.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = Config.class)
|
||||
public class ElasticSearchTest {
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user