Spring

quartz定时任务实例

余生颓废 提交于 2021-02-16 13:04:12
一、spring注解方式 <!--<!–配置文件添加允许Spring注解–>--> <!--<task:annotation-driven scheduler="qbScheduler"/>--> <!--<task:scheduler id="qbScheduler" pool-size="10"/>--> <!--类--> import org.springframework.scheduling.annotation.Scheduled class XXX{ @Scheduled(cron="0 */2 * * * ?") //这里是两分钟触发一次 public void METHOD(){ //方法要做的事 } } 二、XML方式 <?xml version="1.0"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="quartzProperties"> <props><!--用于存储内存中的调度信息--> <prop

Sping Boot入门到实战之实战篇(一):实现自定义Spring Boot Starter——阿里云消息队列服务Starter

喜夏-厌秋 提交于 2021-02-16 11:19:29
  在 Sping Boot入门到实战之入门篇(四):Spring Boot自动化配置 这篇中,我们知道Spring Boot自动化配置的实现,主要由如下几部分完成: @EnableAutoConfiguration注解 SpringApplication类 spring-boot-autoconfigure jar包 spring.factories文件   官方提供的starter,大多包含两个jar包: 一个starter——没有任何实现,只用来管理依赖(spring.providers文件声明),一个autoconfigure包——包含所有具体实现,包括自动配置类,及META-INF/spring.factories文件。自定义starter的时候,可以合并写到一个。   官方提供的starter,命名遵循spring-boot-starter-xx, 自定义starter,命名遵循xx-spring-boot-starter。   本文基于阿里云消息队列RocketMQ服务(https://help.aliyun.com/document_detail/43349.html?spm=a2c4g.11186623.3.2.Ui5KeU),实现一个自定义starter,以实现定时消息与延迟消息(如订单多久未支付自动关闭等)发送与接收功能的快速开发。源码地址: mq

JpaRepository won't save data

泄露秘密 提交于 2021-02-16 11:19:13
问题 I use JpaRepository to save data, but the hibernate.show_sql shows "select" and won't save data. Following is my service: @Autowired private UserRepository userRepository; @PostConstruct public void init() { User admin = new User(); admin.setDisplayName("admin"); admin.setEmailAddress("admin@admin"); admin.setPassword("admin___"); admin.setRegisteredAt(new Date()); admin.setLastAccessAt(new Date()); admin.setUuid(UUID.randomUUID().toString()); try { System.out.println("before save");

Activiti7官方博客翻译3——12个factor的应用

你离开我真会死。 提交于 2021-02-16 10:39:17
要构建云本地应用程序和服务,仅仅在Docker映像中封装旧的整体并在Kubernetes中运行它是不够的。我们重视Heroku定义的被称为“ The Twelve-Factor App ”的原则:https://12factor.net(从关键的角度看 https://content.pivotal.io/ebooks/beyond-the-12-factor-app )。没有这些指导原则,就很难在分布式环境中进行扩展。Activiti Cloud对流程引擎进行了重新定位,以便更好地与此类分布式环境中的其他组件进行交互。Activiti Cloud成功的衡量标准是与其他微服务及其设计、构建和部署方式的低阻抗不匹配。 1.一个代码库,一个应用 我们的示例服务都位于不同的存储库中,每个存储库都表示一个Spring引导应用程序,Spring Cloud库也支持该应用程序。每个服务存储库都包含一组构件,这些构件使它们适合于CI/CD管道: Jenkinsfile:(或其他pipiline定义)管道,用于构建、部署和将当前服务提升到Kubernetes集群。 Maven项目:定义使用Spring Boot和Activiti Cloud starter构建的服务。 Dockerfile:定义如何为服务构建docker映像 HELM Charts:定义一组清单(kubernetes描述符)

configure spring.codec.max-in-memory-size When using ReactiveElasticsearchClient

北城余情 提交于 2021-02-16 10:07:19
问题 I am using the ReactiveElasticsearchClient from spring-data-elasticsearch 3.2.3 with spring-boot 2.2.0. When upgrading to spring-boot 2.2.2 i have got org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144. It's indicated to fixe that to use spring.codec.max-in-memory-size but i still got the same exception. Bellow the whole exception: org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer :

configure spring.codec.max-in-memory-size When using ReactiveElasticsearchClient

China☆狼群 提交于 2021-02-16 10:06:21
问题 I am using the ReactiveElasticsearchClient from spring-data-elasticsearch 3.2.3 with spring-boot 2.2.0. When upgrading to spring-boot 2.2.2 i have got org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144. It's indicated to fixe that to use spring.codec.max-in-memory-size but i still got the same exception. Bellow the whole exception: org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer :

Spring boot 之 dubbo 无xml 简单入门

我们两清 提交于 2021-02-16 10:03:18
Dubbo简介 Dubbo框架设计一共划分了10个层,而最上面的Service层是留给实际想要使用Dubbo开发分布式服务的开发者实现业务逻辑的接口层。图中左边淡蓝背景的为服务消费方使用的接口,右边淡绿色背景的为服务提供方使用的接口, 位于中轴线上的为双方都用到的接口。 下面,结合Dubbo官方文档,我们分别理解一下框架分层架构中,各个层次的设计要点: 服务接口层(Service):该层是与实际业务逻辑相关的,根据服务提供方和服务消费方的业务设计对应的接口和实现。 配置层(Config):对外配置接口,以ServiceConfig和ReferenceConfig为中心,可以直接new配置类,也可以通过spring解析配置生成配置类。 服务代理层(Proxy):服务接口透明代理,生成服务的客户端Stub和服务器端Skeleton,以ServiceProxy为中心,扩展接口为ProxyFactory。 服务注册层(Registry):封装服务地址的注册与发现,以服务URL为中心,扩展接口为RegistryFactory、Registry和RegistryService。可能没有服务注册中心,此时服务提供方直接暴露服务。 集群层(Cluster):封装多个提供者的路由及负载均衡,并桥接注册中心,以Invoker为中心,扩展接口为Cluster、Directory

缘起 Dubbo ,讲讲 Spring XML Schema 扩展机制

大憨熊 提交于 2021-02-16 09:48:20
背景 在 Dubbo 中,可以使用 XML 配置相关信息,也可以用来引入服务或者导出服务。配置完成,启动工程,Spring 会读取配置文件,生成注入 相关 Bean。那 Dubbo 如何实现自定义 XML 被 Spring 加载读取? Spring XML Schema 扩展机制。从 Spring 2.0 开始,Spring 开始提供了一种基于 XML Schema 格式扩展机制,用于定义和配置 bean。 Spring XML Schema 扩展机制 实现 Spring XML Schema 扩展,其实非常简单,只需要完成下面四步。 创建 XML Schema 文件,由于该文件后缀名为 xsd,下面称为 XSD 文件。 编写实现一个或多个 BeanDefinitionParser 。 编写 NamespaceHandler 实现类。 注册 NamespaceHandler 以及 XSD 文件。 我们按照以上步骤,最终完整 Spring 解析如下配置。 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:demo=

How to get raw binary data from a POST request processed by Spring?

血红的双手。 提交于 2021-02-16 06:17:06
问题 I need to write an application which would be able to process binary data sent by CUrl, such as: curl localhost:8080/data --data-binary @ZYSF15A46K1.txt I've created a POST processing method as follows: @RequestMapping(method = RequestMethod.POST, value = "/data") public void acceptData(HttpEntity<byte[]> requestEntity) throws Exception { process(requestEntity.getBody()); } However it doesn't seem to be returning raw binary data. I've tried sending a GZip file and after going through Spring

How to get raw binary data from a POST request processed by Spring?

允我心安 提交于 2021-02-16 06:15:49
问题 I need to write an application which would be able to process binary data sent by CUrl, such as: curl localhost:8080/data --data-binary @ZYSF15A46K1.txt I've created a POST processing method as follows: @RequestMapping(method = RequestMethod.POST, value = "/data") public void acceptData(HttpEntity<byte[]> requestEntity) throws Exception { process(requestEntity.getBody()); } However it doesn't seem to be returning raw binary data. I've tried sending a GZip file and after going through Spring