
spring boot
const伐伐
这个作者很懒,什么都没留下…
展开
-
spring boot 2.2.x 中 actuator tomcat thread相关指标不显示问题
Situation将一个spring boot 1.5.x的工程升级到spring boot 2.2.x,结果发现tomcat thread相关指标没有显示Action试验了2.0.x,2.1.x,访问/actuator/metrics,都是有相关指标的最后去查看spring boot 2.2.x release note,其中写着:在application.properties中添加server.tomcat.mbeanregistry.enable=true...原创 2020-10-10 08:27:00 · 1684 阅读 · 2 评论 -
spring boot中事务功能自动配置的加载过程分析
在spring boot中,默认是启用@EnableTransactionManagement注解的,下面对spring boot支持事务功能的加载过程进行解析在spring boot中,在spring.factories中默认加载了org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa=\org.springframework.boot.autoconfigure.data.jpa.JpaReposito原创 2020-10-01 12:15:22 · 1742 阅读 · 0 评论 -
springboot整合websocket报错:javax.websocket.server.ServerContainer not available
遇到一个问题:在使用springboot整合websocket过程中报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘serverEndpointExporter’…java.lang.IllegalStateException: javax.websocke...原创 2020-03-13 08:53:10 · 6106 阅读 · 2 评论 -
spring boot websocket @OnMessage中使用@Autowired spring bean报null错误
有问题的写法@ClientEndpoint@Componentpublic class SmkCenterConsumer { @Autowired private SmkCenterDataRepository repository; @OnMessage public void onMessage(String message) { ...原创 2020-03-12 14:28:40 · 6407 阅读 · 2 评论 -
源码解析spring boot中websocket endpoint的初始化及启动过程
参考:9.3.17. Create WebSocket Endpoints Using @ServerEndpointspring boot整合websocket源码解析org.springframework.web.socket.server.standard.ServerEndpointExporter#registerEndpoints/** * Actually register...原创 2020-03-12 14:19:22 · 3863 阅读 · 0 评论 -
spring boot actuator management tomcat创建过程解析
当我加入了spring-boot-starter-actuator依赖,启用actuator之后,在application.properties中配置management.port=22223这样spring boot就自动创建了一个tomcat,并将其connector绑定到了此端口上于是我们可以看到一个springboot应用创建了两个嵌入式tomcat容器这一行配置是如何生效的呢...原创 2020-03-03 09:06:28 · 1302 阅读 · 0 评论 -
自定义spring boot嵌入式web容器属性
方法1:直接在application.properties中进行配置server.port=9090方法2:通过代码硬编码的方式进行配置代码参考:https://gitee.com/constfafa/spring_springboot_learning/tree/master/springboot-embedded-tomcat@Configurationpublic class...原创 2020-02-26 14:54:08 · 536 阅读 · 0 评论 -
spring boot中嵌入式web容器是如何初始化及启动的
基于spring boot 1.4.2版本,其tomcat版本通过mvn dependency:tree来查看代码参考:https://gitee.com/constfafa/spring_springboot_learning/tree/master/springboot-embedded-tomcat系统启动 调用SpringApplication.run方法org.spr...原创 2020-02-26 14:04:22 · 609 阅读 · 0 评论 -
解决 Error creating bean with name 'redisConnectionFactory'问题,使spring boot跳过redis连接后启动的方法
场景:今天在开发环境,启动服务做测试的时候,发现一个问题:那就是开发环境没有安装redis,导致spring boot无法启动无法启动的原因是:Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactor...原创 2019-09-11 15:29:41 · 12415 阅读 · 0 评论 -
druid aop_pattern设置不当导致GenericBeanFilter logger is null
场景:数据源使用了druid数据源,其中aop_pattern使用了com.hfi.*这种方式。之前一切正常。引入了二方库之后,发现spring boot服务无法启动,报错: [ ERROR] [2019-08-19 14:52:15] [main] org.springframework.boot.SpringApplication [839] - Application...原创 2019-08-19 16:36:10 · 1456 阅读 · 1 评论 -
将gradle项目作为二方库供其他应用来使用
分为三步:1. 将gradle项目生成带有依赖的jar文件cn.hfi.security-browser就是一个二方库通过加入com.github.jonrengelman.shadow来打包含依赖的jar包参考:https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow2. 安装到本地mav...原创 2019-08-05 20:33:52 · 525 阅读 · 0 评论 -
spring boot整合quartz报错:Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
今天在做spring boot与quartz整合的时候报错org.quartz.SchedulerException: Job instantiation failed at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:47) at org.quartz.co...原创 2018-04-17 17:21:06 · 5304 阅读 · 0 评论 -
spring boot打包成jar并在windows或linux虚拟机上运行
一个spring boot项目,如果能够打包成jar文件,就可以脱离IDE,直接通过java -jar 命令启动,很方便。maven项目第一种方式: Intellij idea下启动先修改pom的packaging为jar打开terminal窗口 cd进入本项目1. 执行mvn clean package可以在target目录下生成springbootweb01-0.0.1-SNAPSHOT.ja...原创 2018-04-13 09:49:35 · 2336 阅读 · 0 评论 -
spring boot操作activemq队列及主题示例
工作过程:1. 搭建消息代理服务器在linux虚拟机上安装activemq,2. 新建spring boot项目,作为producer(1)配置JMS连接工厂ConnectionFactory,让它知道如何连接到ActiveMQ。ActiveMQConnection是ActiveMQ自带的连接工厂。@Beanpublic ConnectionFactory connectionFactory()...原创 2018-06-01 15:46:43 · 2793 阅读 · 0 评论 -
spring boot项目测试controller和service的方法
测试controller@RunWith(SpringRunner.class)@SpringBootTest(classes = {MainApplication.class,MockServletContext.class})public class ReindexTest { private static final Logger LOGGER = LoggerFacto...原创 2018-08-16 11:02:54 · 10538 阅读 · 0 评论 -
spring boot使用jasypt加密原理解析
首先介绍一下jasypt的使用方法可以参考下面这篇文章:Get史上最优雅的加密方式!没有之一!版本对应的坑使用的时候还是遇到一个坑,就是jasypt的版本与spring boot版本存在对应情况。可以看到jasypt是区分java7和java8的,也存在依赖spring版本的情况。自己尝试了一下在使用jasypt-spring-boot-starter的前提下 j...原创 2019-01-16 15:40:00 · 33371 阅读 · 14 评论 -
spring及spring boot中事务相关知识的总结
基础知识1:java事务Java事务的类型有三种:JDBC事务、JTA(Java Transaction API)事务、容器事务。1、JDBC事务JDBC 事务是用 Connection 对象控制的。JDBC Connection 接口( java.sql.Connection )提供了两种事务模式:自动提交和手工提交。 java.sql.Connection 提供了以下控制事务的方法...原创 2019-06-05 09:31:37 · 2973 阅读 · 1 评论 -
spring boot2.x暴露监控endpoint并配置prometheus及grafana对多个targets进行监控
1. build.gradle中添加依赖compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'compile group: 'org.springframework.boot', name: 'spring-boot-starter-security'compile('io.mi...原创 2019-07-25 08:31:10 · 4728 阅读 · 0 评论 -
使用prometheus及grafana监控spring boot 1.x应用程序
背景:spring boot 1.x 程序,构建工具gradle需求:希望能够监控其metrics(包括tomcat相关信息)方法:1. build.gradle中添加依赖compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'compile group: 'org.s...原创 2019-07-23 10:26:39 · 1746 阅读 · 1 评论 -
spring boot 2.0.0下spring-boot-starter-actuator默认endpoints未打开
最近在spring boot 2.0.0下配置spring-boot-starter-actuator,加入依赖后启动,发现spring-boot-starter-actuator2.0.0 RELEASE进行了重构,与之前的spring-boot-actuator的使用大有区别区别1:启动后只显示/actuator/actuator/info/actuator/health其他的endpoint...原创 2018-04-08 20:16:45 · 4533 阅读 · 0 评论