Подумайте об определении bean-компонента с именем'asticsearchTemplate 'в вашей конфигурации. - PullRequest
1 голос
/ 07 июня 2019

Я только что запустил Springboot и попытался реализовать упругий поиск с помощью Spring-Boot, но я получаю этот тип ошибки при запуске приложения Spring-Boot

Подумайте об определении bean-компонента с именем'asticsearchTemplate 'в вашей конфигурации.

pom.xml

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>4.0.0</version>
        </dependency>
         <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>5.6.10</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>


    </dependencies>

Репозиторий

@Repository
public interface StudentRepository extends ElasticsearchRepository<Student, Integer>{}

Контроллер

@RestController
public class Controller {

    @Autowired
    StudentRepository studentRepo;

    @GetMapping(value="/student/all")
    List<Student> getAllStudent() {

        Iterator<Student> studentList = studentRepo.findAll().iterator();
        List<Student> students = new ArrayList<>();
        if(studentList.hasNext()) {
            students.add(studentList.next());
        }
        return students;
    }

    @PostMapping(value="/student/add")
    String addStudent(@RequestBody Student student) {

        studentRepo.save(student);
        return "Record Added Successfully";
    } 

    @DeleteMapping(value="/student/delete/{id}")
    String deleteStudent(@PathVariable int id) {

        studentRepo.deleteById(id);
        return "Record Deleted Successfully";
    }

    //@GetMapping(value="/student/findById/{id}")

}

Может ли кто-нибудь помочь мне решить эту ошибку

Подумайте об определении bean-компонента с именем'asticsearchTemplate 'в вашей конфигурации.

1 Ответ

0 голосов
/ 07 июня 2019

Вам необходимо определить некоторые эластичные свойства поиска в файле application.properties, такие как cluster-nodes, cluster-names, которые используются ElasticsearchTemplate и ElasticsearchRepository для подключения к Elasticsearch двигатель.

Вы можете обратиться по нижеуказанной ссылке:

https://dzone.com/articles/elasticsearch-with-spring-boot-application

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...