feat: 创建 Spring Boot 4 项目及 Gitea/GitLab CI/CD 流水线
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
yangzelin
2026-12-04 13:50:19 +08:00
commit 5c7ee32d17
16 changed files with 720 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
package com.lightjob.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootCiciDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootCiciDemoApplication.class, args);
}
}

View File

@@ -0,0 +1,14 @@
package com.lightjob.demo.controller;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping(value = "/api/hello", produces = MediaType.TEXT_PLAIN_VALUE)
public String hello() {
return "Hello from Spring Boot 4 CI/CD Demo!";
}
}

View File

@@ -0,0 +1,2 @@
spring.application.name=springboot-cici-demo
server.port=8080

View File

@@ -0,0 +1,20 @@
package com.lightjob.demo;
import com.lightjob.demo.controller.HelloController;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@SpringBootTest
class SpringbootCiciDemoApplicationTests {
@Autowired
private HelloController helloController;
@Test
void contextLoads() {
assertNotNull(helloController);
}
}

View File

@@ -0,0 +1,21 @@
package com.lightjob.demo.controller;
import org.junit.jupiter.api.Test;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
class HelloControllerTest {
private final MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new HelloController()).build();
@Test
void helloReturnsPlainText() throws Exception {
mockMvc.perform(get("/api/hello"))
.andExpect(status().isOk())
.andExpect(content().string("Hello from Spring Boot 4 CI/CD Demo!"));
}
}