springboot
王克兵
这个作者很懒,什么都没留下…
展开
-
策略模式对象初始化为空解决方案及项目中具体的使用
使用类:@Componentpublic class TaskReceiver { @Autowired TaskHandlerMapping mapper; @RabbitHandler @RabbitListener(queues = {MqTaskConstant.QUEUE_WS_CAMUNDA_EVENT_TASK} ) public void sendNotice(Message message, Channel channel) th原创 2021-03-18 17:50:06 · 754 阅读 · 1 评论 -
Spring boot Caffeine缓存
1. 引入jar: implementation 'com.github.ben-manes.caffeine:caffeine:2.8.4' implementation('org.springframework.boot:spring-boot-starter-cache')2. 使用配置类配置package com.cnpc.cmp.cmpworksheetapp.config;import com.github.benmanes.caffeine.cache.*;import原创 2021-01-14 17:37:42 · 679 阅读 · 0 评论 -
RestTemplate使用:
1.getForObject()需要把url中参数,用占位符指定到参数对应的key如: String registerUrl = "http://local:2146/oauth2/v1/register?clientId={clientId}";原创 2020-09-09 14:29:29 · 90 阅读 · 0 评论 -
hystrix使用时如果使用了SpringSecurity需要配置一下
在项目中如果使用了springSecurity安全认证,在使用中如果调用远程接口,那么需要主启动类中配置:SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);将SecurityContextHolder 设置为可继承的属性。 因为hystrix会拦截所有的feign远程调用,并重启个线程去调用。因此这时的认证信息 SecurityContextHolder中会取不到。..原创 2020-09-02 16:40:18 · 258 阅读 · 0 评论 -
springboot单元测试
import org.junit.Before;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.context.annotation.Comp.原创 2020-08-06 09:48:53 · 103 阅读 · 0 评论 -
@Transactional 注解使用
rollbackFor和norollbackFor:@Transactional(rollbackFor = Exception.class,noRollbackFor = NullPointerException.class)public Result update(String id, NoticeTemplateDto dto) throws Exception {从使用中看到,如果配置了:noRollbackFor = NullPointerException.class 。1.1 .原创 2020-07-29 16:19:42 · 233 阅读 · 0 评论 -
JPA使用nativeQuery多参数查询注意点
@Query(value = "update pf_process p set p.field_group_id = ?1 where id = ?2 ",nativeQuery = true) @Modifying void updateProcess(String defaultFieldgroupid,String processId); @Query(value = "update pf_process_form p set p.form_config= NULL...原创 2020-06-09 18:38:57 · 3431 阅读 · 0 评论 -
springboot日志输出整合slf4j
1.先引入依赖: <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <depen...原创 2020-01-30 17:14:04 · 1445 阅读 · 0 评论 -
springboot 在linux后台运行
首先需要进到自己springboot项目的根目录,然后执行如下linux命令springboot 后台启动: nohup java -jar aaa-0.0.1-SNAPSHOT.jar >tea.log 2>&1 & nohup java -jar 自己的springboot项目.jar >日志文件名.log 2>&1 &命...转载 2018-12-18 10:15:36 · 339 阅读 · 0 评论 -
idea中spring boot 修改静态资源(js,html) 和 java 不能立即生效,必须重启的解决方案
最近开始使用Idea,有些地方的确比eclipse方便。但是我发现springboot工程每次修改JS或者是JSP页面后,并没有生效,每次修改都需要重启一次,很不方便,找了需要配置,但是效果不佳,终于找到JRebel这个JVM插件,直接热更新,链接在此:https://plugins.jetbrains.com ,也可以从我传的地址上下载: 点击下载 ,安装插件之后,按ctr原创 2018-01-25 14:55:09 · 11608 阅读 · 0 评论