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

《Spring Guides系列学习》guide41 - guide45

要想全面快速学习Spring的内容,最好的方法肯定是先去Spring官网去查阅文档,在Spring官网中找到了适合新手了解的官网Guides,一共68篇,打算全部过一遍,能尽量全面的了解Spring框架的每个特性和功能。
在这里插入图片描述
接着上篇看过的guide41,接着往下看。

guide41、Messaging with JMS

JMS即Java消息服务(Java Message Service)应用程序接口,是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息,进行异步通信。Java消息服务是一个与具体平台无关的API,绝大多数MOM提供商都对JMS提供支持。

创建一个简单的bean

public class Email {private String to;private String body;
...

以及定义一个消息接收器

@Component
public class Receiver {@JmsListener(destination = "mailbox", containerFactory = "myFactory")public void receiveMessage(Email email) {System.out.println("Received <" + email + ">");}
}

JmsListener注释定义了此方法应该侦听的目标的名称,以及用于创建基础消息侦听器容器的JmsListenerContainerFactory的引用。严格来说,最后一个属性不是必须的,除非你需要自定义容器的构建方式,因为Spring Boot会在必要时注册一个默认工厂。

接下来进行消息发送:

@SpringBootApplication
@EnableJms
public class Application {@Beanpublic JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();// This provides all boot's default to this factory, including the message converterconfigurer.configure(factory, connectionFactory);// You could still override some of Boot's default if necessary.return factory;}@Bean // Serialize message content to json using TextMessagepublic MessageConverter jacksonJmsMessageConverter() {MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();converter.setTargetType(MessageType.TEXT);converter.setTypeIdPropertyName("_type");return converter;}public static void main(String[] args) {// Launch the applicationConfigurableApplicationContext context = SpringApplication.run(Application.class, args);JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);// Send a message with a POJO - the template reuse the message converterSystem.out.println("Sending an email message.");jmsTemplate.convertAndSend("mailbox", new Email("info@example.com", "Hello"));}}

为了清晰起见,我们还定义了一个myFactory bean,它在接收器的JmsListener注释中被引用。

默认的MessageConverter只能转换基本类型(例如String、Map、Serializable),我们的电子邮件是不可序列化的。我们想使用Jackson并将内容序列化为文本格式的JSON(即作为TextMessage)。

用JmsTemplate来发送消息,它是Spring提供的一个工具类,和JdbcTemplate类似,可以简化发送消息的代码。

@EnableJMS: Spring根据AppConfig的注解@EnableJms自动扫描带有@JmsListener的Bean方法,并为其创建一个MessageListener把它包装起来。


guide42、Securing a Web Application

讲了spring security的简单使用.

主要是下述代码:

@Configuration
@EnableWebSecurity
public class WebSecurityConfig {@Beanpublic SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {http.authorizeHttpRequests((requests) -> requests.requestMatchers("/", "/home").permitAll().anyRequest().authenticated()).formLogin((form) -> form.loginPage("/login").permitAll()).logout((logout) -> logout.permitAll());return http.build();}@Beanpublic UserDetailsService userDetailsService() {UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build();return new InMemoryUserDetailsManager(user);}}

WebSecurityConfig类添加了@EnableWebSecurity注解,以启用Spring Security的web安全支持,并提供Spring MVC集成。

SecurityFilterChain bean定义哪些URL路径应该被保护,哪些不应该。具体来说,/和/home路径被配置为不需要任何身份验证。所有其他路径都必须经过身份验证。当用户成功登录后,他们会被重定向到之前请求的需要身份验证的页面。有一个自定义/登录页面(由loginPage()指定),每个人都可以查看它。

UserDetailsService bean使用单个用户建立了一个内存中的用户存储。该用户被赋予user用户名、password密码和user角色。


guide43、Accessing Data in Pivotal GemFire

基于Apache Geode数据管理系统构建应用程序的过程

Apache Geode 是一个数据管理平台,可在广泛分布的云架构中提供对数据密集型应用程序的实时、一致的访问。Geode 跨多个进程汇集内存、CPU、网络资源和可选的本地磁盘,以管理应用程序对象和行为。它使用动态复制和数据分区技术来实现高可用性、改进的性能、可伸缩性和容错性。除了作为分布式数据容器之外,Geode 还是一个内存数据管理系统,可提供可靠的异步事件通知和有保证的消息传递。

Apache Geode是一个键值对存储系统,region实现了java.util.concurrent.ConcurrentMap接口。不过你也可以把一个region当作java.util。它比简单的Java Map复杂得多,因为数据是在区域内分发、复制和管理的。

在本例中,通过使用少量注释,将Person对象存储在Apache Geode

@Region(value = "People")
public class Person implements Serializable {@Id@Getterprivate final String name;@Getterprivate final int age;@PersistenceConstructorpublic Person(String name, int age) {this.name = name;this.age = age;}

注意,这个类带有@Region(“People”)注解。当Apache Geode存储这个类的实例时,在People区域中会创建一个新条目。这个类还用@Id标记name字段。这表示用于识别和跟踪Apache Geode中的人员数据的标识符。本质上,带@Id注解的字段(如name)是键,Person实例是键值对条目中的值。在Apache Geode中没有自动生成密钥,因此必须在将实体持久化到Apache Geode之前设置ID(名称)。

@PersistenceConstructor注解:声明构造函数,作用是把从数据库取出的数据实例化为对象。

Spring Data for Apache Geode专注于使用Spring在Apache Geode中存储和访问数据。它还继承了Spring Data Commons项目的强大功能,比如派生查询的能力。

public interface PersonRepository extends CrudRepository<Person, String> {@TracePerson findByName(String name);@TraceIterable<Person> findByAgeGreaterThan(int age);@TraceIterable<Person> findByAgeLessThan(int age);@TraceIterable<Person> findByAgeGreaterThanAndAgeLessThan(int greaterThanAge, int lessThanAge);}

PersonRepository扩展了Spring Data Commons的CrudRepository接口,并为存储库使用的值和ID(键)指定了泛型类型参数的类型(分别是Person和String)。这个接口提供了许多操作,包括基本的CRUD(创建、读取、更新、删除)和简单的查询数据访问操作(例如findById(…))。

@SpringBootApplication
@ClientCacheApplication(name = "AccessingDataGemFireApplication")
@EnableEntityDefinedRegions(basePackageClasses = Person.class,clientRegionShortcut = ClientRegionShortcut.LOCAL
)
@EnableGemfireRepositories
public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}@BeanApplicationRunner run(PersonRepository personRepository) {return args -> {Person alice = new Person("Adult Alice", 40);Person bob = new Person("Baby Bob", 1);Person carol = new Person("Teen Carol", 13);System.out.println("Before accessing data in Apache Geode...");asList(alice, bob, carol).forEach(person -> System.out.println("\t" + person));System.out.println("Saving Alice, Bob and Carol to Pivotal GemFire...");personRepository.save(alice);personRepository.save(bob);personRepository.save(carol);System.out.println("Lookup each person by name...");asList(alice.getName(), bob.getName(), carol.getName()).forEach(name -> System.out.println("\t" + personRepository.findByName(name)));System.out.println("Query adults (over 18):");stream(personRepository.findByAgeGreaterThan(18).spliterator(), false).forEach(person -> System.out.println("\t" + person));System.out.println("Query babies (less than 5):");stream(personRepository.findByAgeLessThan(5).spliterator(), false).forEach(person -> System.out.println("\t" + person));System.out.println("Query teens (between 12 and 20):");stream(personRepository.findByAgeGreaterThanAndAgeLessThan(12, 20).spliterator(), false).forEach(person -> System.out.println("\t" + person));};}
}

需要一个包含一个或多个region的Apache Geode缓存来存储所有数据。要做到这一点,你可以使用Spring的一个数据,为Apache Geode提供方便的基于配置的注解:@ClientCacheApplication。


guide44、Caching Data with Pivotal GemFire

构建一个服务,调用其他地方接口并将结果缓存到appache geode.

新建实体类:

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@SuppressWarnings("unused")public class Quote {
private Long id;
private String quote;... ...
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class QuoteResponse {@JsonProperty("value")private Quote quote;@JsonProperty("type")private String status;...

@SuppressWarnings(“unused”)是一个Java注解,用于抑制未使用变量、方法或参数等代码元素的编译器警告。


@JsonIgnoreProperties(ignoreUnknown=true) 是一个 Jackson 序列化/反序列化注解,用于指示 Jackson 在反序列化 JSON 时忽略未知的属性。

当 Java 对象与 JSON 之间相互转换时,如果 JSON 字符串中包含 Java 对象中没有的属性,Jackson 在默认情况下会抛出异常。使用 @JsonIgnoreProperties(ignoreUnknown=true) 注解可以告诉 Jackson 忽略 JSON 字符串中未知的属性,以避免抛出异常。


@JsonProperty(“value”) 是一个 Jackson 序列化/反序列化注解,用于指示 Jackson 在序列化/反序列化时使用指定的属性名。 Java 对象与 JSON 之间相互转换时,Jackson 默认使用 Java 对象属性的名称作为 JSON 字段的名称。

在创建一个查询quote的服务类

@SuppressWarnings("unused")
@Service
public class QuoteService {protected static final String ID_BASED_QUOTE_SERVICE_URL = "https://quoters.apps.pcfone.io/api/{id}";protected static final String RANDOM_QUOTE_SERVICE_URL = "https://quoters.apps.pcfone.io/api/random";private volatile boolean cacheMiss = false;private final RestTemplate quoteServiceTemplate = new RestTemplate();-- 确定之前的服务方法调用是否导致缓存未命中。   * Determines whether the previous service method invocation resulted in a cache miss.public boolean isCacheMiss() {boolean cacheMiss = this.cacheMiss;this.cacheMiss = false;return cacheMiss;}protected void setCacheMiss() {this.cacheMiss = true;}-- 使用给定的标识符请求一个quote。   * Requests a quote with the given identifier.@Cacheable("Quotes")public Quote requestQuote(Long id) {setCacheMiss();return requestQuote(ID_BASED_QUOTE_SERVICE_URL, Collections.singletonMap("id", id));}-- 请求一个随机quote   * Requests a random quote.@CachePut(cacheNames = "Quotes", key = "#result.id")public Quote requestRandomQuote() {setCacheMiss();return requestQuote(RANDOM_QUOTE_SERVICE_URL);}protected Quote requestQuote(String URL) {return requestQuote(URL, Collections.emptyMap());}protected Quote requestQuote(String URL, Map<String, Object> urlVariables) {return Optional.ofNullable(this.quoteServiceTemplate.getForObject(URL, QuoteResponse.class, urlVariables)).map(QuoteResponse::getQuote).orElse(null);}
}

@Cacheable(“”) 是 Spring 框架提供的注解之一,用于将方法的返回值缓存到缓存中,以便在后续调用时可以直接从缓存中获取结果,从而提高应用程序的性能。

@CachePut(cacheNames = “Quotes”, key = “#result.id”) 是 Spring 框架提供的注解之一,用于将方法的返回值更新缓存中的数据,以便在后续调用时可以直接从缓存中获取最新结果,从而提高应用程序的性能。

与 @Cacheable 注解不同,@CachePut 注解不会检查缓存中是否已经存在相同键值的数据,而是直接将方法的返回值更新到缓存中。其中,cacheNames 参数指定了缓存的名称,key 参数指定了缓存的键,可以使用 SpEL 表达式生成缓存键。

QuoteService使用Spring的RestTemplate来查询Quote服务的API。Quote服务返回一个JSON对象,但Spring使用Jackson将数据绑定到QuoteResponse,最终绑定到Quote对象。

主类:

@SpringBootApplication
@ClientCacheApplication(name = "CachingGemFireApplication")
@EnableCachingDefinedRegions(clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableGemfireCaching
@SuppressWarnings("unused")
public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}@BeanApplicationRunner runner(QuoteService quoteService) {return args -> {Quote quote = requestQuote(quoteService, 12L);requestQuote(quoteService, quote.getId());requestQuote(quoteService, 10L);};}private Quote requestQuote(QuoteService quoteService, Long id) {long startTime = System.currentTimeMillis();Quote quote = Optional.ofNullable(id).map(quoteService::requestQuote).orElseGet(quoteService::requestRandomQuote);long elapsedTime = System.currentTimeMillis();System.out.printf("\"%1$s\"%nCache Miss [%2$s] - Elapsed Time [%3$s ms]%n", quote,quoteService.isCacheMiss(), (elapsedTime - startTime));return quote;}
}

@ClientCacheApplication(name = “CachingGemFireApplication”) 是 Pivotal GemFire 提供的 Spring Boot 集成注解之一,用于在 Spring Boot 应用程序中启用 GemFire 客户端缓存并指定缓存的名称。

@EnableCachingDefinedRegions(clientRegionShortcut = ClientRegionShortcut.LOCAL) 是 Pivotal GemFire 提供的 Spring Boot 集成注解之一,用于在 Spring Boot 应用程序中启用 GemFire 缓存,并定义客户端缓存区域及其行为。

@EnableGemfireCaching 是 Pivotal GemFire 提供的 Spring Boot 集成注解之一,用于在 Spring Boot 应用程序中启用 GemFire 缓存支持。

结果:

Cache Miss [true] - Elapsed Time [776 ms]
Cache Miss [false] - Elapsed Time [0 ms]
Cache Miss [true] - Elapsed Time [96 ms]

guide45、Accessing Data with JPA

使用 Spring Data JPA 在关系数据库中存储和检索数据

Spring Data JPA 是 Spring Framework 提供的一个模块,用于简化与 JPA(Java Persistence
API)的集成。JPA 是 Java EE 规范中的 ORM(对象关系映射)框架,用于将 Java 对象映射到关系数据库。
Spring Data JPA 提供了一组简单且易于使用的 API,用于在 Spring 应用程序中使用
JPA。它提供了自动化存储库(Repository)创建,基于方法名称的查询和 Criteria API 的支持,以及与 Spring 的集成。

构建实体类:

@Entity
public class Customer {@Id@GeneratedValue(strategy= GenerationType.AUTO)private Long id;private String firstName;private String lastName;
...

Spring Data JPA 专注于使用 JPA 将数据存储在关系数据库中。它最引人注目的特性是能够在运行时从存储库接口自动创建存储库实现。

创建一个与实体一起工作的存储库接口:

public interface CustomerRepository extends CrudRepository<Customer, Long> {List<Customer> findByLastName(String lastName);Customer findById(long id);
}

CrudRepository 是 Spring Data JPA 提供的基本存储库接口,它提供了一组简单的 CRUD(创建、读取、更新、删除)操作方法。通过继承 CrudRepository 接口,可以轻松地定义自己的存储库接口,而无需编写任何实现代码。

最后新建主类:

@SpringBootApplication
public class AccessingDataJpaApplication {private static final Logger log = LoggerFactory.getLogger(AccessingDataJpaApplication.class);public static void main(String[] args) {SpringApplication.run(AccessingDataJpaApplication.class);}@Beanpublic CommandLineRunner demo(CustomerRepository repository) {return (args) -> {// save a few customersrepository.save(new Customer("Jack", "Bauer"));repository.save(new Customer("Chloe", "O'Brian"));repository.save(new Customer("Kim", "Bauer"));repository.save(new Customer("David", "Palmer"));repository.save(new Customer("Michelle", "Dessler"));// fetch all customerslog.info("Customers found with findAll():");log.info("-------------------------------");for (Customer customer : repository.findAll()) {log.info(customer.toString());}log.info("");// fetch an individual customer by IDCustomer customer = repository.findById(1L);log.info("Customer found with findById(1L):");log.info("--------------------------------");log.info(customer.toString());log.info("");// fetch customers by last namelog.info("Customer found with findByLastName('Bauer'):");log.info("--------------------------------------------");repository.findByLastName("Bauer").forEach(bauer -> {log.info(bauer.toString());});// for (Customer bauer : repository.findByLastName("Bauer")) {//  log.info(bauer.toString());// }log.info("");};}}

运行结果:

在这里插入图片描述
可以尝试下mapper层代码与spring data的结合,感觉可以少些点CURD代码。

相关文章:

《Spring Guides系列学习》guide41 - guide45

要想全面快速学习Spring的内容&#xff0c;最好的方法肯定是先去Spring官网去查阅文档&#xff0c;在Spring官网中找到了适合新手了解的官网Guides&#xff0c;一共68篇&#xff0c;打算全部过一遍&#xff0c;能尽量全面的了解Spring框架的每个特性和功能。 接着上篇看过的gu…...

数据库基础——1.数据库概述

从这篇文章我们开始学习数据库的相关知识 目录 1.为什么要使用数据库 2.数据库与数据库管理系统 2.1相关概念 2.2数据库与数据库管理系统的关系 ​编辑2.3常见的数据库管理系统 2.4常见的数据库介绍 3.MySQL介绍 3.1概述 3.2关于MySQL8.0 3.3 Oracle vs MySQL 4.RD…...

2023 光亚展|乐鑫将携 AI、Wi-Fi 6、私有云和 Matter 方案精彩亮相

2023 广州国际照明展览会&#xff08;光亚展&#xff09;将于 6 月 9 至 12 日在广州琶洲展馆启幕。本届展会以“光未来”为主题&#xff0c;畅想未来生活方式的无限可能。乐鑫科技 (688018.SH) 将在 B 区 9.2 号厅 D55 展位&#xff0c;带来具有前瞻性的智能照明解决方案和实体…...

用反射设计通用的实例化对象方案

需求 对象的相关信息存储在javabean.properties文件中&#xff0c;通过读取properties文件中的信息&#xff0c;实例化对象&#xff0c;要求程序不能硬编码&#xff0c;即程序可以通用&#xff0c;针对不同的对象&#xff0c;都可以实例化。仅需修改配置文件&#xff0c;不需要…...

破坏单例模式--存在的问题---问题的解决

目录 破坏单例模式--存在的问题---问题的解决 问题演示 破坏单例模式&#xff1a; 序列化 反射 序列化反序列化&#xff1a; 代码&#xff1a; 运行结果&#xff1a; 反射 代码&#xff1a; 运行结果&#xff1a; 问题的解决 序列化、反序列方式破坏单例模式的解…...

SpringCloud微服务踩坑系列-java.lang.IllegalStateException

异常如下&#xff1a; 2023-05-24 08:47:10.764 ERROR 118400 --- [nio-8084-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exceptio…...

Linux-地址空间

文章目录 问题引入操作系统宏观认识操作系统与进程程序地址空间进程地址空间问题解释 问题引入 在Linux操作系统中、vim编译器下&#xff0c;出现了变量同地址但不同值的现象。 下面以解释该现象产生的原因为主线&#xff0c;在过程中学习Linux操作系统的知识。 运行代码展示…...

【EKS】基于Amazon EKS搭建kubernetes集群

文章目录 前言 | 亚马逊云科技 re:Invent前沿资讯一、介绍篇&#x1f3a8;什么是AWS 云计算什么是Amazon EKS 二、部署篇&#x1f528;1、创建集群VPC2、创建集群子网3、创建IGW网关4、创建路由表与子网绑定5、EKS集群创建6、创建kubeconfig配置文件7、添加计算节点组8、查看EK…...

Tomcat安装与启动和配置

目录 Tomcat 简介 Tomcat 安装 Tomcat 启动和配置 文件夹作用 启动&#xff0c;关闭Tomcat&#xff1b; 常见问题 配置 环境变量 IDEA中配置Tomcat Tomcat 简介 Tomcat 服务器是一个免费的开放源代码的Web 应用服务器&#xff0c;属于轻量级应用服务器&#xff0c;在…...

ruoyi-vue版本(十八)创建自己的项目,使用若依里面的技术,多数据源的实现

目录 1 创建自己的项目2 连接MySQL数据库(多数据源)2.1 若依实现多数据源2.1.1 主要思想2.2 第三方的依赖的实现1 创建自己的项目 1 创建一个空文件夹 2 idea 里面创建项目...

C++-stack题型->最小栈,栈的压入与弹出,逆波兰表达式

目录 最小栈 栈的压入与弹出 逆波兰表达式 最小栈 155. 最小栈 - 力扣&#xff08;Leetcode&#xff09; 设计一个支持 push &#xff0c;pop &#xff0c;top 操作&#xff0c;并能在常数时间内检索到最小元素的栈。 实现 MinStack 类: MinStack() 初始化堆栈对象。void …...

【计算机网络实验】BGP和OSPF协议仿真实验

实验内容  BGP和OSPF协议仿真实验 实验目的 &#xff08;1&#xff09;学习BGP协议的配置方法&#xff1b; &#xff08;2&#xff09;验证BGP协议的工作原理&#xff1b; &#xff08;3&#xff09;掌握网络自治系统的划分方法&#xff1b; &#xff08;4&#xff09;验证…...

提升日期处理效率:day.js 实战经验分享

theme: smartblue 本文简介 点赞 关注 收藏 学会了 本文主要介绍我在工作中使用 day.js 较多的方法。本文并不能代替 day.js 官方文档&#xff0c;日常工作中该查文档的还是要查文档。本文是写给刚接触 day.js 的工友&#xff0c;让这部分工友能更顺利上手 day.js。本文不涉…...

mysql中的count(1)、count(*)、count(id)哪个更快?

今天和大家聊一下mysql中的count()方法 我们日常开发中&#xff0c;经常会用到count()命令&#xff0c;有的人用count(*)&#xff0c;有的人用count(1)&#xff0c;还有的人用count(id)&#xff0c;那么这几种写法都有什么区别呢&#xff1f;哪种方法效率更高呢&#xff1f;今…...

cf1750E Bracket Cost

前言&#xff1a; 好久没训练了,来做道计数题找找感觉。**期末毁我青春 大意&#xff1a; 定义对于一个括号串 s的值&#xff0c;为通过最小次数以下操作使 s 实现括号匹配的操作次数。 选择一个子串&#xff0c;循环右移一位。在任意一个位置插入一个任意括号。 求一个括…...

Vue+springboot医院住院挂号登记收费系统7ui9s

医院信息管理系统的开发过程中&#xff0c;采用B / S架构&#xff0c;主要使用java语言进行开发&#xff0c;结合最新流行的springboot框架。使用Mysql数据库和idea开发环境。该医院信息管理系统包括用户、医生和管理员。其主要功能包括用户管理、医生管理、医生信息管理、预约…...

大前端之Koa2学习

Koa2框架介绍 Koa2是一个基于Node.js的Web框架&#xff0c;它使用了ES6的语法和async/await特性&#xff0c;使得编写异步代码更加简单和优雅。Koa2的核心思想是中间件&#xff0c;它允许开发者将应用程序拆分成小的、可重用的部分&#xff0c;从而使得代码更加模块化和易于维…...

Qml实现Dock浮动、停靠功能

纯Qml实现Dock浮动、停靠功能 效果展示github地址:介绍环境Demo代码参数说明API说明 效果展示 Qml Dock效果演示 github地址: https://github.com/longtwilight/QmlDock 介绍 这是一个使用纯qml实现的Dock组件&#xff0c;它支持停靠、浮动、窗体分离、窗体独立、大小调整等…...

最新版本 Stable Diffusion 开源 AI 绘画工具之微调模型篇

✨ 目录 &#x1f388; 模型种类&#x1f388; 变分自动编码器 / VAE&#x1f388; 美学梯度 / Aesthetic Gradients&#x1f388; 大型语言模型的低阶自适应 / LoRA&#x1f388; 超网络模型 / Hypernetwork&#x1f388; 微调模型 / LyCORIS &#x1f388; 模型种类 当你打开…...

路径规划算法:基于哈里斯鹰优化的路径规划算法- 附代码

路径规划算法&#xff1a;基于哈里斯鹰优化的路径规划算法- 附代码 文章目录 路径规划算法&#xff1a;基于哈里斯鹰优化的路径规划算法- 附代码1.算法原理1.1 环境设定1.2 约束条件1.3 适应度函数 2.算法结果3.MATLAB代码4.参考文献 摘要&#xff1a;本文主要介绍利用智能优化…...

Web 应用程序防火墙 (WAF) 相关知识介绍

Web应用程序防火墙 (WAF) 如何工作&#xff1f; Web应用防护系统&#xff08;也称为&#xff1a;网站应用级入侵防御系统。英文&#xff1a;Web Application Firewall&#xff0c;简称&#xff1a;WAF&#xff09;。利用国际上公认的一种说法&#xff1a;Web应用防火墙是通过执…...

docker快速部署hue+hue集成hive

首先需要安装hive&#xff0c;hive的安装在HIVE的安装与配置_EEEurekaaa&#xff01;的博客-CSDN博客 安装完成之后&#xff0c;使用脚本命令启动hdfs和hive的相关服务。 一、安装docker # 安装yum-config-manager配置工具 $ yum -y install yum-utils # 设置yum源 $ yum-co…...

基于java SpringBoot和Vue uniapp的校园信息交流小程序

随着信息社会的网络化和计算机科学的广泛普及和迅速普及应用&#xff0c;具有综合智能的我国校园信息教育网络已成为推动中小学科学教育及其实践科学发展的信息技术手段。迅速推进了信息化改革&#xff0c;改善了高校信息交流的网络环境&#xff0c;提高了信息教育平台的管理水…...

数据包伪造替换、会话劫持、https劫持之探索和测试

&#xff08;一&#xff09;数据包替换攻击 该攻击过程如下&#xff1a;伪造服务器响应客户端的数据包。监听客户端的数据包&#xff0c;用预先伪造的数据包&#xff0c;伪装成服务器返回的数据发送给客户端。 因为攻击者跟目标在同一个局域网&#xff0c;所以攻击者发送的数…...

正则表达式集合

目录 一、校验数字的表达式 1. 数字 2. n位的数字 3. 至少n位的数字 4. m-n位的数字 5. 零和非零开头的数字 6. 非零开头的最多带两位小数的数字 7. 带1-2位小数的正数或负数 8. 正数、负数、和小数 9. 有两位小数的正实数 10. 有1~3位小数的正实数 11. 非零的正整…...

Django框架中models对象转换为json的方法

在django框架中输出api接口时一般都是输出json数据但是通过orm获取的数据库数据一般都是object所以需要转换成json数据&#xff0c;一般有一下3种情况 1.models对象使用“all()”时 from django.http import HttpResponse from django.core import serializers from TestMode…...

利用Servlet编写第一个“hello world“

利用Servlet编写第一个"hello world" &#x1f50e;创建 Maven 项目&#x1f50e;引入依赖&#x1f50e;创建目录&#x1f50e;编写代码&#x1f50e;打包代码&#x1f50e;部署&#x1f50e;程序验证&#x1f50e;结尾 &#x1f50e;创建 Maven 项目 Maven 是一个构…...

python 爬虫之js逆向爬虫详解

随着网站前端技术的不断发展&#xff0c;越来越多的网站采用JS进行渲染&#xff0c;并加上了一些反爬机制&#xff0c;导致传统的爬虫技术有些力不从心。本文将为大家介绍如何进行JS逆向爬虫&#xff0c;并且不少于1000字。 一、JS逆向爬虫的介绍 JS逆向是一种分析反爬机制的…...

SpringBoot:WebSocket实现消息撤回、图片撤回

下面只是讲述一下实现思路&#xff0c;代码基本没有哈&#xff01;有时间单独发表一篇关于websocket的相关操作的博客。 1. 消息撤回、图片撤回 个人觉得关于撤回&#xff0c;需要下述几个过程&#xff1a; 发送的消息的标签上可以定义一个属性&#xff0c;这个属性的值应该是…...

输出指定日期区间内的所有天、周、月

部分方法需要依赖hutool工具包。 <dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>4.5.10</version> </dependency>需求&#xff1a;输出2023-04-17到2023-05-23期间所有的天、周、月。…...