rabbitMQ结合springboot使用(1)
从这一节开始我们进入rabbitMQ的实战环节,项目环境是spring-boot 加maven。首先让我们创建一个spring-boot项目,然后引入web依赖和 rabbitMQ的依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency> <dependency> <groupId>org.spring...
2024-01-10Springboot整合junit过程解析
对maven项目的pom.xml进行配置<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions><!--junit5不需要配置junit-vintage-engine--> <exclusion> <groupId>org.junit.vintage</groupI...
2024-01-10Filter order in spring-boot
如何在spring-boot中指定过滤器的顺序?我需要在Spring Security过滤器之后插入MDC过滤器。我几乎尝试了所有方法,但过滤器始终是第一位的。这不起作用:@Bean@Order(Ordered.LOWEST_PRECEDENCE)public UserInsertingMdcFilter userInsertingMdcFilter() { return new UserInsertingMdcFilter();}这也不起作用:@Beanpublic FilterRegistrati...
2024-01-10Prometheus+Grafana监控SpringBoot
Prometheus 是监控系统,可以从 Springboot 获取监控数据,以时序数据的形式存储,并提供了监控数据的查询服务。Grafana 是专业的 UI 仪表盘系统,支持非常多的数据源,其中就包括 Prometheus,可以便利的从中获取数据,使用仪表盘展示出来。springboot 2 中引入了 micrometer,它可以更方便的对接各种监控系统...
2024-01-10【spring-boot】 springboot整合quartz实现定时任务
本文内容纲要:【spring-boot】 springboot整合quartz实现定时任务在做项目时有时候会有定时器任务的功能,比如某某时间应该做什么,多少秒应该怎么样之类的。spring支持多种定时任务的实现。我们来介绍下使用spring的定时器和使用quartz定时器 1.我们使用spring-boot作为基础框架,其理念为零配置文件...
2024-01-10详解spring boot集成ehcache 2.x 用于hibernate二级缓存
本文将介绍如何在spring boot中集成ehcache作为hibernate的二级缓存。各个框架版本如下spring boot:1.4.3.RELEASEspring framework: 4.3.5.RELEASEhibernate:5.0.1.Final(spring-boot-starter-data-jpa默认依赖)ehcache:2.10.3项目依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spri...
2024-01-10springboot里面工具类注入到bean里面报错
下面是错误,项目把这个bean去掉也是可以的,但是加上为什么会报错呢,请求大佬指点指点一二!回答:加了 @Bean 的方法,返回值会作为bean注册,而参数是所需的依赖所以目测你这个方法并不是干这个事,把 @Bean 去掉就可以了回答:@Bean的作用是:可以自动的返回当前函数返回的数据。而你当前的方法中有个参数,那么如果想让这个方法自动返回数据,就需要自动填充这个参数。@Beanpubli...
2024-03-07Spring整合RabbitMQ04MessageListenerAdapter
RabbitConfigpackage com.wyg.rabbitmq.springamqp;import com.wyg.rabbitmq.springamqp.convert.MyPngMesssageConvert;import com.wyg.rabbitmq.springamqp.convert.MyPDFMessageConvert;import org.springframework.amqp.core.AcknowledgeMode;import org.springframework.a...
2024-01-10spring boot通过@Bean注解定义一个Controller
本文内容纲要:spring boot通过@Bean注解定义一个Controller功能需求提供一个公共的jar包给其他业务模块依赖,需要在这个公共的jar中暴露一个restful API采用spring auto config机制,在公共jar包中定义spring.factories文件,将jar包需要注入到spring容器中的bean定义好,业务模块依赖后直接使用,不需要额外定义bean...
2024-01-10SpringBoot中注入StringRedisTemplate异常
在写一个商城项目中使用了StringRedisTemplate,结果测试启动时报错了:BeanCreationException: Error creating bean with name "userController": Injection of resource dependencies failed,BeanNotOfRequiredTypeException: Bean named "redisTemplate" is expected to be of type "org.springfram...
2024-01-10Spring WebSocket Stomp 整合Vue
描述:将websocket应用在实际的项目中,用于后台应用向浏览器推送消息。架构:传统的springmvc基于xml配置的(但是websocket配置是基于java config配置,可以穿插的配置),前端采用vue.js.启动报错:java.lang.IllegalArgumentException: Async support must be enabled on a servlet and for all filters involved in async request processing. Th...
2024-01-10spring-orm-4.2.6与hibernate-orm-5.2.0不兼容
最新的Hibernate ORM版本(5.2.0)使得SpringORM(最新的4.2.6版)不兼容,因为Hibernate必须将其Session.getFlushMode重命名为Session.getHibernateFlushMode,从而导致此NoSuchMethodError:引起原因:java.lang.NoSuchMethodError:org.hibernate.Session.getFlushMode()Lorg /hibernate / FlushMode;在org.springframe...
2024-01-10Spring RestController的跨域ajax请求问题
我遇到了Ajax跨域请求的问题。以下是我的弹簧控制器的代码:@RestController@RequestMapping(value = "/help")public class MYController { @Autowired private MyService myService; private static final int SUCCESS = 1; private static final int FAIL = 0; ...
2024-01-10Spring Boot整合Spring Data JPA过程解析
Spring Boot整合Spring Data JPA1)加入依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>run...
2024-01-10spring boot 实现配置多个DispatcherServlet最简单方式
传统的web项目,只需要在web.xml里配置多个即可,并且支持多个url-pattern在spring boot中,我们默认无需配置,系统会自动装配一个,感兴趣的可以看下源码org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration里面有个 DispatcherServletRegistrationBean,关键是这里只能指定一个path,如下的源码截图...
2024-01-10Spring Boot,Thymeleaf和@Controller
我正在玩Spring Boot,有一些我不太了解的东西。我的@Controller应用程序中有2s,第二个不是真正接听REST调用,而是Thymeleaf跳过请求。基本上我有:@Configuration@ComponentScan@EnableAutoConfigurationpublic class Application { public static void main(String[] args) throws Throwable { SpringApplicatio...
2024-01-10我可以在spring controller类中使用path变量吗?
弹簧控制器类可以使用路径变量吗?我知道我们可以在控制器的方法中使用路径变量。我们可以以相同的方式将其用于整个课堂吗?例如:@Controller@RequestMapping(value = "{version}/test")class TestController {}我们可以这样使用吗?如果是,我们如何读取{version}变量?实际上,根据我要响应的版本,我需要这...
2024-01-10Spring Boot + JPA2 + Hibernate-启用二级缓存
我正在使用带有JPA2的Spring Boot 1.2.5来注释实体(并hibernate为底层JPA实现)。我想在该设置中使用二级缓存,因此实体带有注释 @javax.persistence.Cacheable我还在application.properties中添加了以下内容:spring.jpa.properties.hibernate.cache.use_second_level_cache=truespring.jpa.properties.hibernate.cache.use_query_c...
2024-01-10Spring+SpringMVC+Mybatis dubbo整合 bean实例化失败
1、问题描述:严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.taotao.service.ItemServic...
2024-01-10springboot Quartz动态修改cron表达式的方法
1、概述: 在开发中有的时候需要去手动禁止和启用定时任务,修改定时任务的cron表达式然后再让其动态生效,之前有过SSM的类似的业务的开发但是忘记写下来了。。。只好重新温习了一次,加上最近比较流行springBoot所以升级了一下用springBoot来完成.2、关联技术 SpringBoot、Quartz、H2、thymeleaf (好像就这...
2024-01-10SpringBoot中配置ApplicationListener监听器的6种方式
1 在application.yml或者在application.properties配置文件中通过context.listener.classes配置2.在resources目录下新建META-INF文件夹并新建spring.factories文件通过org.springframework.context.ApplicationListener配置3. 在启动main函数中通过SpringApplication配置SpringApplication springApplication = new Spri...
2024-01-10SpringBoot系列教程之声明式事务Transactional
200119-SpringBoot 系列教程之声明式事务 Transactional当我们希望一组操作,要么都成功,要么都失败时,往往会考虑利用事务来实现这一点;之前介绍的 db 操作,主要在于单表的 CURD,本文将主要介绍声明式事务@Transactional的使用姿势<!-- more -->I. 配置本篇主要介绍的是jdbcTemplate配合事务注解@Transactional...
2024-01-10如何在Spring Boot中禁用ErrorPageFilter?
我正在创建应在Tomcat上运行的SOAP服务。我正在为我的应用程序使用Spring Boot,类似于:@Configuration@EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class)public class AppConfig {}我的网络服务(示例):@Component@WebServicepublic class MyWebservice { @WebMethod @WebResult public ...
2024-01-10SpringBoot2.X实战SpringBoot整合MongoDB
源代码仓库:https://github.com/zhshuixian/learn-spring-boot-2码云:https://gitee.com/ylooq/learn-spring-boot-2《Spring Boot 2.X 实战》全文在线阅读 -- 微信平台码云 Git Pages https://ylooq.gitee.io/learn-spring-boot-2/#/在数据量日益暴涨的今天,用户的个人信息如浏览点击记录、商品购买记录等成倍增加,传统的 SQL 数据库已经无...
2024-01-10Prometheus 入门教程之SpringBoot 实现自定义指标监控
上篇文章我们已经可以在 Grafana 上看到对应的 SpringBoot 应用信息了,通过这些信息我们可以对 SpringBoot 应用有更全面的监控。但是如果我们需要对一些业务指标做监控,我们应该怎么做呢?这篇文章就带你一步步实现一个模拟的订单业务指标监控。假设我们有一个订单系统,我们需要监控它的实时订...
2024-01-10