Java Spring启动和Travis CI

问题描述 投票:0回答:2

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

命令“ ./mvnw干净安装”以127退出。

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

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

这是我的测试班

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和网络上搜索了几本教程,但似乎无法获得答案。希望大家能帮助我。我非常感激!我也试图删除该脚本,但也没有成功。

java spring-boot maven travis-ci
2个回答
0
投票

我认为您应该将脚本值更改为此:脚本:./ mvn全新安装

我不确定,但您可以尝试


0
投票

返回码127告诉您找不到命令。在这种情况下mvnw。

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

© www.soinside.com 2019 - 2024. All rights reserved.