当前位置: 首页 > news >正文

springboot整合actuator、admin对应用程序进行监控

Spring Boot Actuator 是 Spring Boot 的一个子项目,可以对 Spring Boot 应用程序进行监控和管理,并对外提供了大量的端点,可以选择使用 HTTP 端点或 JMX 来管理和监控应用程序。

这篇文章主要介绍我们的应用程序中怎么加入actuator来对应用进行监控。

首先,需要通过Spring官网访问我们应用程序使用的Springboot版本对应的actutor版本的文档,本篇文章使用Springboot版本为2.3.4.RELEASE,通过以下链接查看文档。

spring boot actuator 2.3.4.RELEASEicon-default.png?t=N7T8https://docs.spring.io/spring-boot/docs/2.3.4.RELEASE/reference/html/production-ready-features.html#production-ready

目录

1、创建Springboot项目

2、整合Spring Boot Actuator

3、暴露所有端点

4、整合Spring Boot Admin

搭建Spring Boot Admin Server

创建Spring Boot Admin Client

5、整合Spring Security


1、创建Springboot项目

通过IntelliJ IDEA创建一个名为actuator项目

然后修改pom.xml文件,将spring boot的版本修改为2.3.4.RELEASE。

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.4.RELEASE</version><relativePath />
</parent>

2、整合Spring Boot Actuator

根据Spring官网的文档,在我们的springboot应用中加入actuator非常简单,只需要一个maven依赖:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

完整的项目依赖如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.4.RELEASE</version><relativePath/></parent><groupId>com.example</groupId><artifactId>actuator</artifactId><version>0.0.1-SNAPSHOT</version><properties><java.version>1.8</java.version></properties><dependencies><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>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
</project>

最后设置一下启动端口,修改application.yml配置文件,添加端口配置:

server:port: 8077

然后访问localhost:端口号/actuator,可以看到返回了很多个http链接地址,这些就是actuator默认提供给我们获取应用信息的端点。

http://localhost:8077/actuator/info用于获取应用的信息,这个端点默认返回空数据,这个是需要我们自己配置的。

http://localhost:8077/actuator/health用于获取服务的健康状态,如果服务依赖的所有中间件都是正常状态,这里会返回一个UP,表示在线状态。

health端点默认只返回了一个状态,可以通过以下配置,让端点返回详细的信息。

management:endpoint:health:show-details: always

然后重启项目,再次访问health端点:

3、暴露所有端点

上一步中,我们访问actuator只返回了两个端点:health和info,其实actuator提供的端点远不止这些,官网提供的jmx环境和web环境下各个端点的开放情况。

IDJMXWeb

auditevents

Yes

No

beans

Yes

No

caches

Yes

No

conditions

Yes

No

configprops

Yes

No

env

Yes

No

flyway

Yes

No

health

Yes

Yes

heapdump

N/A

No

httptrace

Yes

No

info

Yes

Yes

integrationgraph

Yes

No

jolokia

N/A

No

logfile

N/A

No

loggers

Yes

No

liquibase

Yes

No

metrics

Yes

No

mappings

Yes

No

prometheus

N/A

No

scheduledtasks

Yes

No

sessions

Yes

No

shutdown

Yes

No

threaddump

Yes

No

那么,其他端点怎么暴露出来呢,让我们访问http://localhost:8077/actuator就能得到所有可用端点。

步骤:修改application.yml,添加暴露所有端点的配置

server:port: 8077management:endpoint:health:show-details: always # 显示健康状态详情endpoints:web:exposure:include: "*" # 暴露所有端点base-path: /actuator

这里的端点endpoint可以理解为Controller接口,通过端点可以获取应用的详细信息,包括实例健康状态、配置信息、映射信息、缓存信息等等。

关于具体每个端点的功能,就不一一介绍了,可以通过页面进行查看。

这是Springboot Actuator 2.3.4.RELEASE版本返回的所有端点。

{"_links": {"self": {"href": "http://localhost:8091/actuator","templated": false},"beans": {"href": "http://localhost:8091/actuator/beans","templated": false},"caches-cache": {"href": "http://localhost:8091/actuator/caches/{cache}","templated": true},"caches": {"href": "http://localhost:8091/actuator/caches","templated": false},"health-path": {"href": "http://localhost:8091/actuator/health/{*path}","templated": true},"health": {"href": "http://localhost:8091/actuator/health","templated": false},"info": {"href": "http://localhost:8091/actuator/info","templated": false},"conditions": {"href": "http://localhost:8091/actuator/conditions","templated": false},"configprops": {"href": "http://localhost:8091/actuator/configprops","templated": false},"env": {"href": "http://localhost:8091/actuator/env","templated": false},"env-toMatch": {"href": "http://localhost:8091/actuator/env/{toMatch}","templated": true},"loggers": {"href": "http://localhost:8091/actuator/loggers","templated": false},"loggers-name": {"href": "http://localhost:8091/actuator/loggers/{name}","templated": true},"heapdump": {"href": "http://localhost:8091/actuator/heapdump","templated": false},"threaddump": {"href": "http://localhost:8091/actuator/threaddump","templated": false},"metrics-requiredMetricName": {"href": "http://localhost:8091/actuator/metrics/{requiredMetricName}","templated": true},"metrics": {"href": "http://localhost:8091/actuator/metrics","templated": false},"scheduledtasks": {"href": "http://localhost:8091/actuator/scheduledtasks","templated": false},"mappings": {"href": "http://localhost:8091/actuator/mappings","templated": false}}
}

4、整合Spring Boot Admin

那么,actuator提供给我们那么多端点,不可能每次都通过这些端点来获取应用信息吧,太麻烦了,有没有一种更好的方式可以方便又快捷的查看应用程序的状态信息呢。

这个时候就需要引入Spring Boot Admin了,github可能访问缓慢或者无法访问,这里提供了gitee的仓库地址。

Spring Boot Adminicon-default.png?t=N7T8https://gitee.com/pujiaolin/spring-boot-admin介绍:什么是Spring Boot Admin?

Spring Boot Admin 是一款用于管理和监控 Spring Boot 应用程序的简单应用程序。应用程序可在我们的 Spring Boot 管理客户端(通过 http)注册,也可使用 Spring Cloud(如 Eureka)发现。用户界面只是 Spring Boot Actuator 端点之上的一个 Angular.js 应用程序。

搭建Spring Boot Admin Server

接下来开始整合Spring Boot Admin,根据官网介绍,要先设置admin的服务器

通过idea创建一个Springboot项目,取名为admin-server

然后修改pom.xml,添加相关依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.4.RELEASE</version><relativePath /></parent><groupId>com.example</groupId><artifactId>admin-server</artifactId><version>0.0.1-SNAPSHOT</version><properties><java.version>1.8</java.version></properties><dependencies><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>de.codecentric</groupId><artifactId>spring-boot-admin-starter-server</artifactId><version>2.3.1</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
</project>

并在启动类上添加@EnableAdminServer注解

这样,admin的服务端就搭建好了,然后访问localhost:8080,看到的就是admin的界面,因为还没有客户端注册,所以应用数为0

创建Spring Boot Admin Client

创建完服务器,需要往服务器注册客户端应用程序。

同样的,通过idea创建一个Springboot应用,取名为admin-client

修改pom.xml,添加admin客户端的依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.4.RELEASE</version><relativePath/></parent><groupId>com.example</groupId><artifactId>admin-client</artifactId><version>0.0.1-SNAPSHOT</version><properties><java.version>1.8</java.version></properties><dependencies><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>de.codecentric</groupId><artifactId>spring-boot-admin-starter-client</artifactId><version>2.3.1</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
</project>

然后修改配置文件application.yml,配置admin服务器的URL,因为admin-server没有配置端口,默认是8080,并把第一步actuator服务的配置复制过来。

server:port: 8081spring:boot:admin:client:url: http://localhost:8080management:endpoints:web:exposure:include: "*"base-path: /actuatorendpoint:health:show-details: always

启动客户端服务admin-client,再次访问localhost:8080,可以看到,客户端已经注册到了服务器

5、整合Spring Security

通过第四步,已经搭建好了admin,但是存在很严重的安全问题,任何人都可以访问程序的运行状态和信息,这个章节通过整合Spring Security来解决这个问题,配置登录才能访问。

点击Spring Boot Admin官网左边的目录链接,直接跳转到Security

根据要求,在admin-server端添加一个配置类,按需修改用户名和密码

package com.example.adminserver.config;import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;import java.util.UUID;/*** @author heyunlin* @version 1.0*/
@Configuration(proxyBeanMethods = false)
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {private final AdminServerProperties adminServer;public SecuritySecureConfig(AdminServerProperties adminServer) {this.adminServer = adminServer;}@Overrideprotected void configure(HttpSecurity http) throws Exception {SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();successHandler.setTargetUrlParameter("redirectTo");successHandler.setDefaultTargetUrl(this.adminServer.path("/"));http.authorizeRequests((authorizeRequests) -> authorizeRequests.antMatchers(this.adminServer.path("/assets/**")).permitAll().antMatchers(this.adminServer.path("/login")).permitAll().anyRequest().authenticated()).formLogin((formLogin) -> formLogin.loginPage(this.adminServer.path("/login")).successHandler(successHandler).and()).logout((logout) -> logout.logoutUrl(this.adminServer.path("/logout"))).httpBasic(Customizer.withDefaults()).csrf((csrf) -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).ignoringRequestMatchers(new AntPathRequestMatcher(this.adminServer.path("/instances"),HttpMethod.POST.toString()),new AntPathRequestMatcher(this.adminServer.path("/instances/*"),HttpMethod.DELETE.toString()),new AntPathRequestMatcher(this.adminServer.path("/actuator/**")))).rememberMe((rememberMe) -> rememberMe.key(UUID.randomUUID().toString()).tokenValiditySeconds(1209600));}// Required to provide UserDetailsService for "remember functionality"@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {auth.inMemoryAuthentication().withUser("user").password("12345").roles("USER");}}

然后重启admin-server,再次访问localhost:8080的时候,发现要登录

输入刚刚设置的用户名/密码:user/12345,点击登录按钮

这时候发现页面只是刷新了一下,并没有跳转到首页,这里也是个坑。

查看服务器报错信息

点第二行的matches()方法进去看看

很显然,就是因为这里主动抛出的异常导致的登录失败,往鼠标上面滚动,这是一个PasswordEncoder的实现类

由此可见,这是默认调用的这个实现类的matches()方法,为了解决这个异常问题,我们需要在admin-server自己创建一个org.springframework.security.crypto.password.PasswordEncoder的实现类,并声明为bean,然后重写matches()方法,直接通过equals()比较即可。

package com.example.adminserver;import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;/*** @author heyunlin* @version 1.0*/
@Component
public class MyPasswordEncoder implements PasswordEncoder {@Overridepublic String encode(CharSequence rawPassword) {return null;}@Overridepublic boolean matches(CharSequence rawPassword, String encodedPassword) {return rawPassword.equals(encodedPassword);}}

然后再次重启admin-server,这一次输入user/12345点击登录,成功进到了首页,但是,客户端怎么没了,居然没有注册进来。

接着看文档,后面还有很关键的说明,需要在客户端添加下面这个配置,用户名密码就是刚刚设置的用户名user和密码12345。

修改admin-client的application.yml,添加用户名和密码的配置,然后重启一下admin-client服务

server:port: 8081spring:boot:admin:client:username: userpassword: 12345url: http://localhost:8080management:endpoints:web:exposure:include: "*"base-path: /actuatorendpoint:health:show-details: always

这时候再看刚才的页面,已经成功注册进来了

最后,因为用户名密码是写死在代码里的,一般希望能过通过配置文件动态修改。

在配置文件中配置用户名和密码

server:port: 8080spring:security:user:name: userpassword: 12345

修改一下配置类,从配置中读取用户名和密码

package com.example.adminserver.config;import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;import java.util.UUID;/*** @author heyunlin* @version 1.0*/
@Configuration(proxyBeanMethods = false)
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {private final AdminServerProperties adminServer;private final SecurityProperties securityProperties;public SecuritySecureConfig(AdminServerProperties adminServer, SecurityProperties securityProperties) {this.adminServer = adminServer;this.securityProperties = securityProperties;}@Overrideprotected void configure(HttpSecurity http) throws Exception {SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();successHandler.setTargetUrlParameter("redirectTo");successHandler.setDefaultTargetUrl(this.adminServer.path("/"));http.authorizeRequests((authorizeRequests) -> authorizeRequests.antMatchers(this.adminServer.path("/assets/**")).permitAll().antMatchers(this.adminServer.path("/login")).permitAll().anyRequest().authenticated()).formLogin((formLogin) -> formLogin.loginPage(this.adminServer.path("/login")).successHandler(successHandler).and()).logout((logout) -> logout.logoutUrl(this.adminServer.path("/logout"))).httpBasic(Customizer.withDefaults()).csrf((csrf) -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).ignoringRequestMatchers(new AntPathRequestMatcher(this.adminServer.path("/instances"),HttpMethod.POST.toString()),new AntPathRequestMatcher(this.adminServer.path("/instances/*"),HttpMethod.DELETE.toString()),new AntPathRequestMatcher(this.adminServer.path("/actuator/**")))).rememberMe((rememberMe) -> rememberMe.key(UUID.randomUUID().toString()).tokenValiditySeconds(1209600));}// Required to provide UserDetailsService for "remember functionality"@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {auth.inMemoryAuthentication().withUser(securityProperties.getUser().getName()).password(securityProperties.getUser().getPassword()).roles("USER");}}

6、注册到注册中心

以admin-server为例,将其注册到nacos。

添加nacos相关依赖,注册中心和配置中心的依赖都加进来,统一管理配置信息。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.4.RELEASE</version><relativePath /></parent><groupId>com.example</groupId><artifactId>admin-server</artifactId><version>0.0.1-SNAPSHOT</version><properties><java.version>1.8</java.version><admin.version>2.3.1</admin.version><nacos.version>2.2.0.RELEASE</nacos.version></properties><dependencies><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>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency><dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-server</artifactId><version>${admin.version}</version></dependency><!--nacos注册中心--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>${nacos.version}</version></dependency><!--nacos配置中心--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>${nacos.version}</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
</project>

然后创建bootstrap.yml,添加nacos注册中心和配置中心配置

nacos:url: localhost:8848namespace: 0df4345c-cf1e-4af4-9501-d4be92ca6fdaspring:cloud:nacos:discovery:register-enabled: trueserver-addr: ${nacos.url}namespace: ${nacos.namespace}config:file-extension: yamlserver-addr: ${nacos.url}namespace: ${nacos.namespace}

最后,需要设置spring.application.name,否则不会注册到nacos

server:port: 8080spring:security:user:name: userpassword: 12345application:name: admin-server

启动nacos服务,然后再启动admin-server,在nacos控制台的服务列表,成功看到了注册进来的的admin-server

admin-server注册到注册中心之后,会自动拉取添加了spring-boot-starter-admin-client依赖的服务,所以需要删除客户端配置,否则将会有两个同一服务的实例注册到admin服务器。

修改admin-client服务的配置文件application.yml,删除之前添加的admin客户端配置。

server:port: 8081management:endpoints:web:exposure:include: "*"base-path: /actuatorendpoint:health:show-details: always

关于nacos如何使用,可以参考博主的另一篇文章:

nacos作为注册中心和配置中心icon-default.png?t=N7T8https://blog.csdn.net/heyl163_/article/details/128536799好了,以上就是本篇文章要分享的全部内容了,看完不要忘了点赞+收藏哦~

文章中涉及的项目均已上传到gitee,需要的可以下载到本地:

actuatoricon-default.png?t=N7T8https://gitee.com/he-yunlin/actuator.gitspring boot整合admin实现对应用监控服务器项目icon-default.png?t=N7T8https://gitee.com/he-yunlin/admin-server.gitSpring Boot Admin Client项目icon-default.png?t=N7T8https://gitee.com/he-yunlin/admin-client.git

相关文章:

springboot整合actuator、admin对应用程序进行监控

Spring Boot Actuator 是 Spring Boot 的一个子项目&#xff0c;可以对 Spring Boot 应用程序进行监控和管理&#xff0c;并对外提供了大量的端点&#xff0c;可以选择使用 HTTP 端点或 JMX 来管理和监控应用程序。 这篇文章主要介绍我们的应用程序中怎么加入actuator来对应用进…...

文举论金:黄金原油全面走势分析策略指导。

市场没有绝对&#xff0c;涨跌没有定势&#xff0c;所以&#xff0c;对市场行情的涨跌平衡判断就是你的制胜法宝。欲望&#xff01;有句意大利谚语&#xff1a;让金钱成为我们忠心耿耿的仆人&#xff0c;否则&#xff0c;它就会成为一个专横跋扈的主人。空头&#xff0c;多头都…...

Fedora CoreOS 安装部署详解

《OpenShift 4.x HOL教程汇总》 Fedora CoreOS 的裸机安装方法_fedora coreos 安装-CSDN博客 OpenShift 4 - Fedora CoreOS (1) - 最简安装_fedora core 安装_dawnsky.liu的博客-CSDN博客 OpenShift 和 CoreOS 我们知道 Red Hat Enterprise Linux CoreOS&#xff08;简称RHCOS&…...

Web应用开发 - 实训三 B Servlet基础

Web应用开发 - 实训三 B Servlet基础 前言&#xff1a; 零、前期准备准备工具创建项目导入 jar 包配置运行设置 一、实训第一部分第一张图第二张图第三张图 二、实训第二部分第一张图第二张图 前言&#xff1a; eclipse 是不可能用的&#xff0c;并不是说它界面丑&#xff0c;…...

Debian12安装 Docker

Docker中基本概念 镜像(Image) 镜像&#xff0c;从认识上简单的来说&#xff0c;就是面向对象中的类&#xff0c;相当于一个模板。从本质上来说&#xff0c;镜像相当于一个文件系统。Docker 镜像是一个特殊的文件系统&#xff0c;除了提供容器运行时所需的程序、库、资源、配…...

Elasticsearch:为具有许多 and/or 高频术语的 top-k 查询带来加速

作者&#xff1a;Adrien Grand Disjunctive queries&#xff08;term_1 OR term_2 OR ... OR term_n&#xff09;非常常用&#xff0c;因此在提高查询评估效率方面它们受到了广泛关注。 Apache Lucene 对于评估 disjunctive queries 有两个主要优化&#xff1a;一方面用于详尽评…...

【pythonflask-1】简单实现加减乘除输入界面

app.py import flask from flask import Flask, render_template, request # 计算精确的浮点结果&#xff0c;float加法也计算不出来 from decimal import Decimalapp Flask(__name__)app.route(/) def home():return render_template(index.html)app.route(/calculate, meth…...

基于协同过滤算法的旅游推荐系统

博主主页&#xff1a;猫头鹰源码 博主简介&#xff1a;Java领域优质创作者、CSDN博客专家、公司架构师、全网粉丝5万、专注Java技术领域和毕业设计项目实战 主要内容&#xff1a;毕业设计(Javaweb项目|小程序等)、简历模板、学习资料、面试题库、技术咨询 文末联系获取 项目介绍…...

遇见问题:使用mybaties向数据库中插入数据,idea显示插入成功,但是数据库中并没有数据变化?

遇见问题&#xff1a;使用mybaties向数据库中插入数据&#xff0c;idea显示插入成功&#xff0c;但是数据库中并没有数据变化? 可能的原因有几种&#xff1a; 没有提交事务&#xff1a;在使用 MyBatis 进行数据库操作时&#xff0c;需要手动提交事务。你可以在插入数据完成后…...

markdown学习笔记

markdown学习笔记 1.文字&#xff08;依靠HTML&#xff09; 1.1文字缩进-空格转义符 单字符空&#xff1a;&emsp; 半字符空&#xff1a;&ensp;1.2文字对齐 「居中&#xff1a;」<center> 居中 </center> or <p align"center"> 居中 …...

C++项目实战——基于多设计模式下的同步异步日志系统-⑧-日志落地类设计

文章目录 专栏导读抽象基类StdoutSink类设计FileSink类设计RollBySizeSink类设计日志落地工厂类设计日志落地类整理日志落地拓展测试RollByTimeSink类设计测试代码测试完整代码 专栏导读 &#x1f338;作者简介&#xff1a;花想云 &#xff0c;在读本科生一枚&#xff0c;C/C领…...

从零开始探索C语言(八)----指针

文章目录 1. 什么是指针&#xff1f;2. 如何使用指针&#xff1f;3. NULL 指针4. 指针的算术运算5. 指针数组6. 指向指针的指针7. 传递指针给函数8. 从函数返回指针 有人说&#xff0c;指针是C语言的灵魂&#xff0c;所以学习C语言&#xff0c;学习指针是很有必要的。 通过指针…...

SpringMVC 的三种异常处理方式详解

目录 1. 什么是异常 2. 为什么要全局异常处理 3. SpringMVC异常分类 4. 异常处理思路 5. 三种异常处理方式示例 ① 配置 SimpleMappingExceptionResolver 处理器 ② 实现 HandlerExceptionResolver 接口 ③ 使用ControllerAdviceExceptionHandler实现全局异常 6. 响应…...

莫比乌斯召回系统介绍

当前召回系统只能召回相关性高的广告&#xff0c;但不能保证该广告变现能力强。莫比乌斯做了如下两点创新&#xff1a; 在召回阶段&#xff0c;引入CPM等业务指标作为召回依据在召回阶段&#xff0c;引入CTR模型&#xff0c;从而召回更多相关性高且变现能力强的广告 参考 百度…...

使用ASM修改组件化 ARouter

工程目录图 1. apt生成的字节码文件 2. asm 生成的代码 请点击下面工程名称&#xff0c;跳转到代码的仓库页面&#xff0c;将工程 下载下来 Demo Code 里有详细的注释 代码&#xff1a;TestCompont...

第21章_瑞萨MCU零基础入门系列教程之事件链接控制器ELC

本教程基于韦东山百问网出的 DShanMCU-RA6M5开发板 进行编写&#xff0c;需要的同学可以在这里获取&#xff1a; https://item.taobao.com/item.htm?id728461040949 配套资料获取&#xff1a;https://renesas-docs.100ask.net 瑞萨MCU零基础入门系列教程汇总&#xff1a; ht…...

(二十八)大数据实战——Flume数据采集之kafka数据生产与消费集成案例

前言 本节内容我们主要介绍一下flume数据采集和kafka消息中间键的整合。通过flume监听nc端口的数据&#xff0c;将数据发送到kafka消息的first主题中&#xff0c;然后在通过flume消费kafka中的主题消息&#xff0c;将消费到的消息打印到控制台上。集成使用flume作为kafka的生产…...

vue3:22、vue-router的使用

import { createRouter, createWebHistory } from vue-router//history模式&#xff1a;createWebHistory //hash模式&#xff1a;createWebHashHistory//vite中的环境变量 import.meta.env.BASE_URL 就是vite.config.js中的base配置项 const router createRouter({history:…...

深入理解JVM虚拟机第五篇:一些常用的JVM虚拟机(二)

文章目录 一&#xff1a;JRockit VM的介绍 二&#xff1a;J9 VM的介绍 三&#xff1a;KVM和CDC/CLDC Hotspot 四&#xff1a;Azul VM的介绍 五&#xff1a;Liquid VM的介绍 六&#xff1a;Apache Harmoney 七&#xff1a;Microsoft JVM 八&#xff1a;Taobao JVM 九&a…...

导数公式及求导法则

目录 基本初等函数的导数公式 求导法则 有理运算法则 复合函数求导法 隐函数求导法 反函数求导法 参数方程求导法 对数求导法 基本初等函数的导数公式 基本初等函数的导数公式包括&#xff1a; C0(x^n)nx^(n-1)(a^x)a^x*lna(e^x)e^x(loga(x))1/(xlna)(lnx)1/x(sinx)cos…...

【JavaEE】-- HTTP

1. HTTP是什么&#xff1f; HTTP&#xff08;全称为"超文本传输协议"&#xff09;是一种应用非常广泛的应用层协议&#xff0c;HTTP是基于TCP协议的一种应用层协议。 应用层协议&#xff1a;是计算机网络协议栈中最高层的协议&#xff0c;它定义了运行在不同主机上…...

UE5 学习系列(三)创建和移动物体

这篇博客是该系列的第三篇&#xff0c;是在之前两篇博客的基础上展开&#xff0c;主要介绍如何在操作界面中创建和拖动物体&#xff0c;这篇博客跟随的视频链接如下&#xff1a; B 站视频&#xff1a;s03-创建和移动物体 如果你不打算开之前的博客并且对UE5 比较熟的话按照以…...

Qwen3-Embedding-0.6B深度解析:多语言语义检索的轻量级利器

第一章 引言&#xff1a;语义表示的新时代挑战与Qwen3的破局之路 1.1 文本嵌入的核心价值与技术演进 在人工智能领域&#xff0c;文本嵌入技术如同连接自然语言与机器理解的“神经突触”——它将人类语言转化为计算机可计算的语义向量&#xff0c;支撑着搜索引擎、推荐系统、…...

安宝特案例丨Vuzix AR智能眼镜集成专业软件,助力卢森堡医院药房转型,赢得辉瑞创新奖

在Vuzix M400 AR智能眼镜的助力下&#xff0c;卢森堡罗伯特舒曼医院&#xff08;the Robert Schuman Hospitals, HRS&#xff09;凭借在无菌制剂生产流程中引入增强现实技术&#xff08;AR&#xff09;创新项目&#xff0c;荣获了2024年6月7日由卢森堡医院药剂师协会&#xff0…...

CSS | transition 和 transform的用处和区别

省流总结&#xff1a; transform用于变换/变形&#xff0c;transition是动画控制器 transform 用来对元素进行变形&#xff0c;常见的操作如下&#xff0c;它是立即生效的样式变形属性。 旋转 rotate(角度deg)、平移 translateX(像素px)、缩放 scale(倍数)、倾斜 skewX(角度…...

热门Chrome扩展程序存在明文传输风险,用户隐私安全受威胁

赛门铁克威胁猎手团队最新报告披露&#xff0c;数款拥有数百万活跃用户的Chrome扩展程序正在通过未加密的HTTP连接静默泄露用户敏感数据&#xff0c;严重威胁用户隐私安全。 知名扩展程序存在明文传输风险 尽管宣称提供安全浏览、数据分析或便捷界面等功能&#xff0c;但SEMR…...

深入浅出WebGL:在浏览器中解锁3D世界的魔法钥匙

WebGL&#xff1a;在浏览器中解锁3D世界的魔法钥匙 引言&#xff1a;网页的边界正在消失 在数字化浪潮的推动下&#xff0c;网页早已不再是静态信息的展示窗口。如今&#xff0c;我们可以在浏览器中体验逼真的3D游戏、交互式数据可视化、虚拟实验室&#xff0c;甚至沉浸式的V…...

SpringCloud优势

目录 完善的微服务支持 高可用性和容错性 灵活的配置管理 强大的服务网关 分布式追踪能力 丰富的社区生态 易于与其他技术栈集成 完善的微服务支持 Spring Cloud 提供了一整套工具和组件来支持微服务架构的开发,包括服务注册与发现、负载均衡、断路器、配置管理等功能…...

【系统架构设计师-2025上半年真题】综合知识-参考答案及部分详解(回忆版)

更多内容请见: 备考系统架构设计师-专栏介绍和目录 文章目录 【第1题】【第2题】【第3题】【第4题】【第5题】【第6题】【第7题】【第8题】【第9题】【第10题】【第11题】【第12题】【第13题】【第14题】【第15题】【第16题】【第17题】【第18题】【第19题】【第20~21题】【第…...

盲盒一番赏小程序:引领盲盒新潮流

在盲盒市场日益火爆的今天&#xff0c;如何才能在众多盲盒产品中脱颖而出&#xff1f;盲盒一番赏小程序给出了答案&#xff0c;它以创新的玩法和优质的服务&#xff0c;引领着盲盒新潮流。 一番赏小程序的最大特色在于其独特的赏品分级制度。赏品分为多个等级&#xff0c;从普…...