首页 > 其他分享 >springboot 单元测试

springboot 单元测试

时间:2024-02-19 10:55:25浏览次数:26  
标签:shop springboot 单元测试 cx org test import class

 

 

package com.cx.shop.scheduler.test;

import com.cx.shop.SchedulerProviderApplication;
import com.cx.shop.scheduler.service.TaskJobService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

@SpringBootTest(classes = SchedulerProviderApplication.class)
@RunWith(SpringRunner.class)
public class TaskTest {

    @Resource
    private TaskJobService taskJobService;

    @Test
    public void conflictTime() {
        this.taskJobService.runOnce(1732589160625348609L);
    }

}

 

标签:shop,springboot,单元测试,cx,org,test,import,class
From: https://www.cnblogs.com/p201821460026/p/18020603

相关文章

  • springboot中,各部分的作用
    一个优秀的Controller层逻辑,它的定位,我认为是「不可或缺的配角」 说它是配角是因为Controller层的代码一般是不负责具体的逻辑业务逻辑实现,但是它负责接收和响应请求 Controller主要的工作有以下几项接收请求并解析参数调用Service执行具体的业务代码(可能包含参数......
  • Spring/SpringBoot 拦截器
    Spring/SpringBoot拦截器拦截器的作用:拦截器,可以进行请求过滤、权限管理、打印日志、数据校验等。拦截器,可以在请求前、请求后进行处理。代码示例:拦截器MyInterceptor:Spring的拦截器,需要实现HandlerInterceptor接口。publicclassMyInterceptorimplementsHandler......
  • Java21 + SpringBoot3使用Spring Security时如何在子线程中获取到认证信息
    目录前言原因分析解决方案方案1:手动设置线程中的认证信息方案2:使用DelegatingSecurityContextRunnable创建线程方案3:修改SpringSecurity安全策略通过设置JVM参数修改安全策略通过SecurityContextHolder修改安全策略总结前言近日心血来潮想做一个开源项目,目标是做一款可以适配多......
  • springboot的web项目部署_前后端整合部署
    springboot的web项目部署[2]_前后端整合部署vite.config.ts  build:{   //build编译后存放静态文件的目录   outDir:"../renren-admin/src/main/resources/static",  ShiroConfig.javafilterMap.put("/**/*.html","anon");filterMap.put(&......
  • SpringBoot整合OSS中的设计模式----单例模式
    在SpringBoot项目中使用OSS存储上传的图片,需要配置OSS设置信息。避免对象的重复创建,确保一个类只有一个实例,并提供一个全局访问点来访问该实例,于是用到了单例模式,这里复习一下单例模式。单线程----懒汉式@Data@Component@ConfigurationProperties(prefix="aliyun.oss")pu......
  • Java与SpringBoot网站的重构
    Java简介Java特点: Java的运行原理: SpringBoot网站的重构有源码的情况后台重构(mysql+maven+jdk+网站源码)将网站源码放入idea软件中查看重要配置文件:pom.xml和application.propertiespom.xml有网站的jdk版本和打包软件而application.properites文件中有着数据库的配......
  • springboot自定义starter 版本大于2.7
    相关jar包<!--提示配置--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><version>3.2.1</versi......
  • 大年初二学习SpringBoot之权限管理
    1增加spring-security依赖目前市面上主流的权限框架是:spring-security和shiro,shrio使用起来更简单,而spring-security的功能更强大。苏三商城项目选择的权限框架是:spring-security。首先要加入spring-security的相关依赖包。在项目中的pom.xml文件中增加如下依赖:<dependency......
  • springboot整合redis报错:链接失败;org.springframework.data.redis.RedisConnectionFai
    错误原因:开启了保护模式解决方案:关闭保护模式和防火墙具体步骤:1、打开你的redis配置文件,做出如下修改2.开启进程守护yes代表开启守护进程模式。在该模式下,redis会在后台运行,并将进程pid号写入至redis.conf选项pidfile设置的文件中,此时redis将一直运行,除非手动kill该进程。3.......
  • Springboot项目中使用Elasticsearch的RestClient
    上一篇介绍了Elasticsearch的入门《5000字详说Elasticsearch入门(一)》,本篇介绍Springboot如何集成使用Elasticsearch。分为3步:配置properties文件、引入pom依赖、配置RestHighLevelClient类。1、选择ES的ClientAPI我们知道Elasticsearch是一款RestfulAPI风格的分布式搜索引擎......