package com.imooc.diners;
import com.imooc.diners.service.SignService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;
@SpringBootTest(classes = {DinersApplication.class})
public class RedisApplicationTest {
@Autowired
StringRedisTemplate redisTemplate;
@Autowired
SignService signService;
@Test
public void testInit() {
System.out.println("-------");
signService.doSign2("a1eebaff-074c-468f-88cd-57c9775d3efd","2021-11-01");
System.out.println("-------");
}
}
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
如果某个对象没有注入,就时要加入这个。
@SpringBootTest(classes = {DinersApplication.class})
2021年8月20日
Description:
A component required a bean of type 'com.tese.api.service.CheckInService' that could not be found.
@Service
public class CheckInServiceImpl implements CheckInService{
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class CheckInServiceImplTest {
@Resource
CheckInServiceImpl CheckInServiceImpl;
@Test
public void getDayCheckInInfo2() {
System.out.println("CheckInServiceImpl.getDayCheckInLog() = " + CheckInServiceImpl.getDayCheckInLog());
}