国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

springboot整合elasticsearch使用案例

這篇具有很好參考價值的文章主要介紹了springboot整合elasticsearch使用案例。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

引入依賴

<dependency>
   <groupId>org.elasticsearch.client</groupId>
   <artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>

添加注入

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@MapperScan("cn.itcast.hotel.mapper")
@SpringBootApplication
public class HotelDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(HotelDemoApplication.class, args);
    }

    @Bean
    public RestHighLevelClient client(){
        return  new RestHighLevelClient(RestClient.builder(
                HttpHost.create("http://43.139.59.28:9200")
        ));
    }

}

搜索和分頁

完成關(guān)鍵字搜索和分頁

model類

import lombok.Data;

@Data
public class RequestParams {
    private String key;
    private Integer page;
    private Integer size;
    private String sortBy;
}

?返回類

import lombok.Data;

import java.util.List;

@Data
public class PageResult {
    private Long total;
    private List<HotelDoc> hotels;

    public PageResult() {
    }

    public PageResult(Long total, List<HotelDoc> hotels) {
        this.total = total;
        this.hotels = hotels;
    }
}

controller類

@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private IHotelService hotelService;
	// 搜索酒店數(shù)據(jù)
    @PostMapping("/list")
    public PageResult search(@RequestBody RequestParams params){
        return hotelService.search(params);
    }
}

Service類

import cn.itcast.hotel.mapper.HotelMapper;
import cn.itcast.hotel.pojo.Hotel;
import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;

import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Service
public class HotelService extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {

    @Autowired
    private RestHighLevelClient client;

    @Override
    public PageResult search(RequestParams params) {
        try {
            // 1.準(zhǔn)備Request
            SearchRequest request = new SearchRequest("hotel");
            // 2.準(zhǔn)備DSL
            // 2.1.query
            String key = params.getKey();
            if (key == null || "".equals(key)) {
                request.source().query(QueryBuilders.matchAllQuery());
            } else {
                request.source().query(QueryBuilders.matchQuery("all", key));
            }

            // 2.2.分頁
            int page = params.getPage();
            int size = params.getSize();
            request.source().from((page - 1) * size).size(size);

            // 3.發(fā)送請求
            SearchResponse response = client.search(request, RequestOptions.DEFAULT);
            // 4.解析響應(yīng)
            return handleResponse(response);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    // 結(jié)果解析
    private PageResult handleResponse(SearchResponse response) {
        // 4.解析響應(yīng)
        SearchHits searchHits = response.getHits();
        // 4.1.獲取總條數(shù)
        long total = searchHits.getTotalHits().value;
        // 4.2.文檔數(shù)組
        SearchHit[] hits = searchHits.getHits();
        // 4.3.遍歷
        List<HotelDoc> hotels = new ArrayList<>();
        for (SearchHit hit : hits) {
            // 獲取文檔source
            String json = hit.getSourceAsString();
            // 反序列化
            HotelDoc hotelDoc = JSON.parseObject(json, HotelDoc.class);
            // 放入集合
            hotels.add(hotelDoc);
        }
        // 4.4.封裝返回
        return new PageResult(total, hotels);
    }
}

發(fā)出請求

springboot整合elasticsearch使用案例,elasticsearch,spring boot,elasticsearch,jenkins

結(jié)果過濾

添加品牌、城市、星級、價格等過濾功能

model類

import lombok.Data;

@Data
public class RequestParams {
    private String key;
    private Integer page;
    private Integer size;
    private String sortBy;
    // 下面是新增的過濾條件參數(shù)
    private String city;
    private String brand;
    private String starName;
    private Integer minPrice;
    private Integer maxPrice;
}

?service類

 @Override
    public PageResult search(RequestParams params) {
        try {
            // 1.準(zhǔn)備Request
            SearchRequest request = new SearchRequest("hotel");
            // 2.準(zhǔn)備DSL
            // 2.1.query
           buildBasicQuery(params,request);

            // 2.2.分頁
            int page = params.getPage();
            int size = params.getSize();
            request.source().from((page - 1) * size).size(size);

            // 3.發(fā)送請求
            SearchResponse response = client.search(request, RequestOptions.DEFAULT);
            // 4.解析響應(yīng)
            return handleResponse(response);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    private void buildBasicQuery(RequestParams params, SearchRequest request) {
        // 1.構(gòu)建BooleanQuery
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
        // 2.關(guān)鍵字搜索
        String key = params.getKey();
        if (key == null || "".equals(key)) {
            boolQuery.must(QueryBuilders.matchAllQuery());
        } else {
            boolQuery.must(QueryBuilders.matchQuery("all", key));
        }
        // 3.城市條件
        if (params.getCity() != null && !params.getCity().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("city", params.getCity()));
        }
        // 4.品牌條件
        if (params.getBrand() != null && !params.getBrand().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("brand", params.getBrand()));
        }
        // 5.星級條件
        if (params.getStarName() != null && !params.getStarName().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("starName", params.getStarName()));
        }
        // 6.價格
        if (params.getMinPrice() != null && params.getMaxPrice() != null) {
            boolQuery.filter(QueryBuilders
                    .rangeQuery("price")
                    .gte(params.getMinPrice())
                    .lte(params.getMaxPrice())
            );
        }
        // 7.放入source
        request.source().query(boolQuery);
    }

發(fā)出請求

springboot整合elasticsearch使用案例,elasticsearch,spring boot,elasticsearch,jenkins

搜索附近

搜索我附近的酒店 ?

model類

import lombok.Data;

@Data
public class RequestParams {
    private String key;
    private Integer page;
    private Integer size;
    private String sortBy;
    private String city;
    private String brand;
    private String starName;
    private Integer minPrice;
    private Integer maxPrice;
    // 我當(dāng)前的地理坐標(biāo)
    private String location;
}

文檔類?

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class HotelDoc {
    private Long id;
    private String name;
    private String address;
    private Integer price;
    private Integer score;
    private String brand;
    private String city;
    private String starName;
    private String business;
    private String location;
    private String pic;
    // 排序時的 距離值
    private Object distance;
    public HotelDoc(Hotel hotel) {
        this.id = hotel.getId();
        this.name = hotel.getName();
        this.address = hotel.getAddress();
        this.price = hotel.getPrice();
        this.score = hotel.getScore();
        this.brand = hotel.getBrand();
        this.city = hotel.getCity();
        this.starName = hotel.getStarName();
        this.business = hotel.getBusiness();
        this.location = hotel.getLatitude() + ", " + hotel.getLongitude();
        this.pic = hotel.getPic();
    }
}

service類

import cn.itcast.hotel.mapper.HotelMapper;
import cn.itcast.hotel.pojo.Hotel;
import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;

import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Service
public class HotelService extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {

    @Autowired
    private RestHighLevelClient client;

    @Override
    public PageResult search(RequestParams params) {
        try {
            // 1.準(zhǔn)備Request
            SearchRequest request = new SearchRequest("hotel");
            // 2.準(zhǔn)備DSL
            // 2.1.query
            buildBasicQuery(params, request);

            // 2.2.分頁
            int page = params.getPage();
            int size = params.getSize();
            request.source().from((page - 1) * size).size(size);

            // 2.3.排序
            String location = params.getLocation();
            if (location != null && !location.equals("")) {
                request.source().sort(SortBuilders
                        .geoDistanceSort("location", new GeoPoint(location))
                        .order(SortOrder.ASC)
                        .unit(DistanceUnit.KILOMETERS)
                );
            }

            // 3.發(fā)送請求
            SearchResponse response = client.search(request, RequestOptions.DEFAULT);
            // 4.解析響應(yīng)
            return handleResponse(response);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    private void buildBasicQuery(RequestParams params, SearchRequest request) {
        // 1.構(gòu)建BooleanQuery
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
        // 2.關(guān)鍵字搜索
        String key = params.getKey();
        if (key == null || "".equals(key)) {
            boolQuery.must(QueryBuilders.matchAllQuery());
        } else {
            boolQuery.must(QueryBuilders.matchQuery("all", key));
        }
        // 3.城市條件
        if (params.getCity() != null && !params.getCity().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("city", params.getCity()));
        }
        // 4.品牌條件
        if (params.getBrand() != null && !params.getBrand().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("brand", params.getBrand()));
        }
        // 5.星級條件
        if (params.getStarName() != null && !params.getStarName().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("starName", params.getStarName()));
        }
        // 6.價格
        if (params.getMinPrice() != null && params.getMaxPrice() != null) {
            boolQuery.filter(QueryBuilders
                    .rangeQuery("price")
                    .gte(params.getMinPrice())
                    .lte(params.getMaxPrice())
            );
        }
        // 7.放入source
        request.source().query(boolQuery);
    }

    // 結(jié)果解析
    private PageResult handleResponse(SearchResponse response) {
        // 4.解析響應(yīng)
        SearchHits searchHits = response.getHits();
        // 4.1.獲取總條數(shù)
        long total = searchHits.getTotalHits().value;
        // 4.2.文檔數(shù)組
        SearchHit[] hits = searchHits.getHits();
        // 4.3.遍歷
        List<HotelDoc> hotels = new ArrayList<>();
        for (SearchHit hit : hits) {
            // 獲取文檔source
            String json = hit.getSourceAsString();
            // 反序列化
            HotelDoc hotelDoc = JSON.parseObject(json, HotelDoc.class);
            // 獲取排序值
            Object[] sortValues = hit.getSortValues();
            if (sortValues.length > 0) {
                Object sortValue = sortValues[0];
                hotelDoc.setDistance(sortValue);
            }
            // 放入集合
            hotels.add(hotelDoc);
        }
        // 4.4.封裝返回
        return new PageResult(total, hotels);
    }
}

發(fā)送請求

springboot整合elasticsearch使用案例,elasticsearch,spring boot,elasticsearch,jenkins

競價排名

?讓指定的酒店在搜索結(jié)果中排名置頂

修改索引庫

添加isAD字段

PUT /hotel/_mapping
{
  "properties":{
    "isAD":{
      "type":"boolean"
    }
  }
}

springboot整合elasticsearch使用案例,elasticsearch,spring boot,elasticsearch,jenkins

修改文檔?

POST /hotel/_update/1393017952
{
    "doc": {
        "isAD": true
    }
}

springboot整合elasticsearch使用案例,elasticsearch,spring boot,elasticsearch,jenkins

model類

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class HotelDoc {
    private Long id;
    private String name;
    private String address;
    private Integer price;
    private Integer score;
    private String brand;
    private String city;
    private String starName;
    private String business;
    private String location;
    private String pic;
    private Object distance;
    // 添加廣告標(biāo)記
    private Boolean isAD;
    public HotelDoc(Hotel hotel) {
        this.id = hotel.getId();
        this.name = hotel.getName();
        this.address = hotel.getAddress();
        this.price = hotel.getPrice();
        this.score = hotel.getScore();
        this.brand = hotel.getBrand();
        this.city = hotel.getCity();
        this.starName = hotel.getStarName();
        this.business = hotel.getBusiness();
        this.location = hotel.getLatitude() + ", " + hotel.getLongitude();
        this.pic = hotel.getPic();
    }
}

service類



import cn.itcast.hotel.mapper.HotelMapper;
import cn.itcast.hotel.pojo.Hotel;
import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;

import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Service
public class HotelService extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {

    @Autowired
    private RestHighLevelClient client;

    @Override
    public PageResult search(RequestParams params) {
        try {
            // 1.準(zhǔn)備Request
            SearchRequest request = new SearchRequest("hotel");
            // 2.準(zhǔn)備DSL
            // 2.1.query
            buildBasicQuery(params, request);

            // 2.2.分頁
            int page = params.getPage();
            int size = params.getSize();
            request.source().from((page - 1) * size).size(size);

            // 2.3.排序
            String location = params.getLocation();
            if (location != null && !location.equals("")) {
                request.source().sort(SortBuilders
                        .geoDistanceSort("location", new GeoPoint(location))
                        .order(SortOrder.ASC)
                        .unit(DistanceUnit.KILOMETERS)
                );
            }

            // 3.發(fā)送請求
            SearchResponse response = client.search(request, RequestOptions.DEFAULT);
            // 4.解析響應(yīng)
            return handleResponse(response);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    private void buildBasicQuery(RequestParams params, SearchRequest request) {
        // 1.構(gòu)建BooleanQuery
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
        // 關(guān)鍵字搜索
        String key = params.getKey();
        if (key == null || "".equals(key)) {
            boolQuery.must(QueryBuilders.matchAllQuery());
        } else {
            boolQuery.must(QueryBuilders.matchQuery("all", key));
        }
        // 城市條件
        if (params.getCity() != null && !params.getCity().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("city", params.getCity()));
        }
        // 品牌條件
        if (params.getBrand() != null && !params.getBrand().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("brand", params.getBrand()));
        }
        // 星級條件
        if (params.getStarName() != null && !params.getStarName().equals("")) {
            boolQuery.filter(QueryBuilders.termQuery("starName", params.getStarName()));
        }
        // 價格
        if (params.getMinPrice() != null && params.getMaxPrice() != null) {
            boolQuery.filter(QueryBuilders
                    .rangeQuery("price")
                    .gte(params.getMinPrice())
                    .lte(params.getMaxPrice())
            );
        }

        // 2.算分控制
        FunctionScoreQueryBuilder functionScoreQuery =
                QueryBuilders.functionScoreQuery(
                        // 原始查詢,相關(guān)性算分的查詢
                        boolQuery,
                        // function score的數(shù)組
                        new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{
                                // 其中的一個function score 元素
                                new FunctionScoreQueryBuilder.FilterFunctionBuilder(
                                        // 過濾條件
                                        QueryBuilders.termQuery("isAD", true),
                                        // 算分函數(shù)
                                        ScoreFunctionBuilders.weightFactorFunction(10)
                                )
                        });
        request.source().query(functionScoreQuery);
    }

    // 結(jié)果解析
    private PageResult handleResponse(SearchResponse response) {
        // 4.解析響應(yīng)
        SearchHits searchHits = response.getHits();
        // 4.1.獲取總條數(shù)
        long total = searchHits.getTotalHits().value;
        // 4.2.文檔數(shù)組
        SearchHit[] hits = searchHits.getHits();
        // 4.3.遍歷
        List<HotelDoc> hotels = new ArrayList<>();
        for (SearchHit hit : hits) {
            // 獲取文檔source
            String json = hit.getSourceAsString();
            // 反序列化
            HotelDoc hotelDoc = JSON.parseObject(json, HotelDoc.class);
            // 獲取排序值
            Object[] sortValues = hit.getSortValues();
            if (sortValues.length > 0) {
                Object sortValue = sortValues[0];
                hotelDoc.setDistance(sortValue);
            }
            // 放入集合
            hotels.add(hotelDoc);
        }
        // 4.4.封裝返回
        return new PageResult(total, hotels);
    }
}

發(fā)送請求

springboot整合elasticsearch使用案例,elasticsearch,spring boot,elasticsearch,jenkins文章來源地址http://www.zghlxwxcb.cn/news/detail-704387.html

到了這里,關(guān)于springboot整合elasticsearch使用案例的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Spring Boot進(jìn)階(19):Spring Boot 整合ElasticSearch | 超級詳細(xì),建議收藏

    Spring Boot進(jìn)階(19):Spring Boot 整合ElasticSearch | 超級詳細(xì),建議收藏

    ????????ElasticSearch是一款基于Lucene的開源搜索引擎,具有高效、可擴(kuò)展、分布式的特點(diǎn),可用于全文搜索、日志分析、數(shù)據(jù)挖掘等場景。Spring Boot作為目前最流行的微服務(wù)框架之一,也提供了對ElasticSearch的支持。本篇文章將介紹如何在Spring Boot項目中整合ElasticSearch,并展

    2024年02月06日
    瀏覽(31)
  • SSMP整合案例(2) Spring Boot整合Lombok簡化實體類開發(fā)

    SSMP整合案例(2) Spring Boot整合Lombok簡化實體類開發(fā)

    好啊 接著我們上文SSMP整合案例(1) 構(gòu)建 Spring Boot Vue MySql項目環(huán)境 我們繼續(xù) 接下來 我們要在java項目中 建立出數(shù)據(jù)庫表對應(yīng)的實體類 我們還是先看看自己上文中 創(chuàng)建的這個 book表 其中四個字段 主鍵id 數(shù)字枚舉類型的type 字符串類型name 字符串類型 description 我們打開idea 找到上

    2024年02月09日
    瀏覽(21)
  • Spring Boot整合Elasticsearch超詳細(xì)教程

    SpringBoot整合Elasticsearch超詳細(xì)教程 最新高級版 (1)導(dǎo)入springboot整合ES高級別客戶端的坐標(biāo) (2)使用編程的形式設(shè)置連接的ES服務(wù)器,并獲取客戶端對象 (3)Book實體類 (4)連接Dao層 (5)使用客戶端對象操作ES 例如創(chuàng)建索引:(這里需要先執(zhí)行上面的刪除索引操作,否則會報錯)

    2023年04月09日
    瀏覽(25)
  • 在Spring Boot中整合Elasticsearch并實現(xiàn)高亮搜索

    本文詳細(xì)介紹了如何在Spring Boot項目中整合Elasticsearch,實現(xiàn)高亮搜索功能。通過添加依賴、配置Spring Boot、為實體類添加注解,以及在Service層實現(xiàn)高亮搜索,讀者能夠了解如何在實際項目中利用Spring Boot Data Elasticsearch來操作Elasticsearch并實現(xiàn)高亮搜索。驗證示例演示了如何使用RESTful API端點(diǎn)來搜索并獲取包含高亮字段的用戶列表,為讀者提供了實際應(yīng)用的參考。這篇文章將幫助讀者輕松掌握Spring Boot與Elasticsearch的整合方法,從而為項目增加強(qiáng)大的搜索功能。

    2024年02月06日
    瀏覽(29)
  • 知識點(diǎn)13--spring boot整合elasticsearch以及ES高亮

    知識點(diǎn)13--spring boot整合elasticsearch以及ES高亮

    本章知識點(diǎn)沿用知識點(diǎn)12的項目,介紹如何使用spring boot整合ES,沒有ES的去我主頁 各類型大數(shù)據(jù)集群搭建文檔--大數(shù)據(jù)原生集群本地測試環(huán)境搭建三 中可以看到ES如何搭建 不管你有沒有ES,最好是沒有,因為一定要知道一點(diǎn),一定要去官網(wǎng)查一下你當(dāng)前用的spring boot data es的版

    2024年02月12日
    瀏覽(97)
  • 【項目實戰(zhàn)】一、Spring boot整合JWT、Vue案例展示用戶鑒權(quán)

    【項目實戰(zhàn)】Spring boot整合JWT、Vue案例展示用戶鑒權(quán) 【微服務(wù)實戰(zhàn)】JWT

    2024年02月09日
    瀏覽(20)
  • Springboot 實踐(13)spring boot 整合RabbitMq

    前文講解了RabbitMQ的下載和安裝,此文講解springboot整合RabbitMq實現(xiàn)消息的發(fā)送和消費(fèi)。 1、創(chuàng)建web project項目,名稱為“SpringbootAction-RabbitMQ” 2、修改pom.xml文件,添加amqp使用jar包 ?? !--? RabbitMQ -- ??? ????dependency ??????????? groupIdorg.springframework.boot/groupId ????????

    2024年02月09日
    瀏覽(23)
  • SpringBoot--中間件技術(shù)-3:整合mongodb,整合ElasticSearch,附案例含代碼(簡單易懂)

    實現(xiàn)步驟: pom文件導(dǎo)坐標(biāo) yaml配置文件配置mongodb: 隨便建一個pojo 測試: 裝配MongoTemplate模板類,調(diào)用方法 整合MongoDB總結(jié): 導(dǎo)坐標(biāo) 寫配置文件 核心類MongoTemplate調(diào)用 前提準(zhǔn)備:數(shù)據(jù)庫+ES 數(shù)據(jù)庫建表語句: 實現(xiàn)步驟: pom文件到坐標(biāo) yaml配置文件 創(chuàng)建實體類: 對應(yīng)數(shù)據(jù)庫表

    2024年02月04日
    瀏覽(20)
  • 【SpringBoot】Spring Boot 項目中整合 MyBatis 和 PageHelper

    目錄 前言? ? ? ?? 步驟 1: 添加依賴 步驟 2: 配置數(shù)據(jù)源和 MyBatis 步驟 3: 配置 PageHelper 步驟 4: 使用 PageHelper 進(jìn)行分頁查詢 IDEA指定端口啟動 總結(jié) ????????Spring Boot 與 MyBatis 的整合是 Java 開發(fā)中常見的需求,特別是在使用分頁插件如 PageHelper 時。PageHelper 是一個針對 MyBat

    2024年04月25日
    瀏覽(32)
  • 【Spring Boot】SpringBoot 優(yōu)雅整合Swagger Api 自動生成文檔

    【Spring Boot】SpringBoot 優(yōu)雅整合Swagger Api 自動生成文檔

    Swagger 是一套 RESTful API 文檔生成工具,可以方便地生成 API 文檔并提供 API 調(diào)試頁面。 而 Spring Boot 是一款非常優(yōu)秀的 Java Web 開發(fā)框架,它可以非常方便地構(gòu)建 Web 應(yīng)用程序。 在本文中,我們將介紹如何使用 Swagger 以及如何在 Spring Boot 中整合 Swagger 。 首先,在 pom.xml 文件中添

    2023年04月22日
    瀏覽(25)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包