jenkins - SpringBootTest 在詹金斯上导致非法状态异常
问题描述
按照此处https://spring.io/guides/gs/testing-web/的说明进行了我们的 Spring Boot 应用程序和测试设置,例如
@SpringBootTest
class ApisApplicationTests {
@Test
void contextLoads() {
}
}
@SpringBootTest
class SonarQubeClientTest {
@Autowired
private SonarQubeClient sonarQubeClient;
@Autowired
private RestTemplate restTemplate;
private MockRestServiceServer mockServer;
@BeforeEach
public void init() {
mockServer = MockRestServiceServer.createServer(restTemplate);
}
@Test
void deleteProject() throws Exception {
mockServer.expect(ExpectedCount.once(),
requestTo(new URI("https://sonar-prod.xxxxxxxxxx.int/api/projects/delete")))
.andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.NO_CONTENT));
sonarQubeClient.deleteProject("fake-service");
mockServer.verify();
}
}
gradle 在本地构建完美,但由于某种原因,在 jenkins 上构建时,我们不断遇到上述测试的相同失败:
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:798
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:798
Caused by: org.springframework.beans.factory.BeanCreationException at ConstructorResolver.java:314
Caused by: org.springframework.beans.BeanInstantiationException at BeanUtils.java:216
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException at DataSourceUtils.java:82
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException at SQLError.java:174
Caused by: com.mysql.cj.exceptions.CJCommunicationsException at NativeConstructorAccessorImpl.java:-2
Caused by: javax.net.ssl.SSLHandshakeException at HandshakeContext.java:170
有人可以帮忙吗?提前谢谢。
解决方案
推荐阅读
- neo4j - Neo4j 4.3 - 弃用大小函数和模式理解
- python - PyCharm "ModuleNotFoundError: No module named 'win32com.shell'" 即使通过 pip 安装了 pypiwin32 和 pywin32
- android - 使用 XAMARIN 获取 GPS 位置,即使 GPS 关闭
- c++ - 您认为我可以如何解决错误 C2664?
- python - Pandas:如何编写一个更快的循环来检查一列,然后根据第一列的值更改另一列的符号?
- python - 不根据 dict 换房间
- json - 使用python将json数据嵌套到数据表中
- c++ - 为什么将浮点表示与精度结合起来不起作用?
- gradle - 如何使用 gradle 将预构建的工件发布到 maven 存储库?
- windows - Powershell-错误:权限被拒绝,以管理员身份运行 ps1 文件时出现 UnauthorizedAccessException