gpt4 book ai didi

Java Spring boot 和 Travis CI

转载 作者:行者123 更新时间:2023-12-01 18:08:46 27 4
gpt4 key购买 nike

我正在尝试使用 Travis CI 自动运行我的测试。我只是找不到关于如何在 java 中执行此操作的好教程。当我推送到 GitHub 时,我在 Travis 中不断收到以下错误:

The command "./mvnw clean install" exited with 127.

我的 .travis.yml 文件如下所示:

language: java
jdk:
- openjdk11
script: ./mvnw clean install

这是我的测试类(class)

package server;

import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@WebMvcTest(CoffeeController.class)
@RunWith(SpringRunner.class)
class CoffeeControllerTest {

@Autowired
private MockMvc mockMvc;

@Test
void getAllCoffee() {
try {
mockMvc.perform(get("/coffee/all")).andExpect(status().isOk());
} catch (Exception e) {
e.printStackTrace();
}
}
}

我在 Youtube 和网络上搜索了几个教程,但似乎找不到答案。我希望你们中的任何人都可以帮助我。我非常感激!我也尝试删除该脚本,但没有成功。

最佳答案

返回代码 127 告诉您找不到该命令。在本例中为 mvnw。

请检查一下您的 mvnw(mvn 包装器)是否在 PATH 中,或者尝试使用绝对路径。另外,mvnw 应该是项目的一部分,如果没有推送,您可以推送它,或者使用带有 mvn 的 openjdk 来构建您的应用程序。

关于Java Spring boot 和 Travis CI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60506070/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com