12 Commits

Author SHA1 Message Date
fb5cc69a60 补充健康检查信息 2019-08-18 19:16:06 +08:00
b1102b472c 使用jetty容器 2019-08-18 19:07:57 +08:00
cb264276dc 修改启动配置 2019-08-18 16:35:44 +08:00
b7cbe93e7c 修改ci配置 2019-08-18 16:26:02 +08:00
ac19ac7c78 修改ci配置 2019-08-18 16:19:16 +08:00
4774b36930 修改ci配置 2019-08-18 16:17:22 +08:00
9ee84b9243 修改ci配置 2019-08-18 16:12:45 +08:00
267f7672e2 修改ci配置 2019-08-18 16:10:16 +08:00
56c4c56386 修改ci配置 2019-08-18 16:06:44 +08:00
9de7591256 修改ci配置 2019-08-18 16:04:10 +08:00
ff7c8d9620 修改ci配置 2019-08-18 16:01:07 +08:00
2a44f2c94f 暴露健康检查端口,添加README.MD 2019-08-18 15:51:59 +08:00
5 changed files with 107 additions and 5 deletions

View File

@@ -4,7 +4,11 @@ services:
variables:
DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci
DOCKER_TLS_CERTDIR: "/certs"
IMAGE_VERSION: $CI_COMMIT_REF_NAME
before_script:
- "echo 构建版本号: ${IMAGE_VERSION}"
stages:
- build
@@ -13,6 +17,8 @@ stages:
maven-build:
image: maven:3-jdk-8
stage: build
tags:
- 8T
script: "mvn package -B"
artifacts:
paths:
@@ -20,7 +26,10 @@ maven-build:
docker-build:
stage: package
tags:
- 8T
script:
- docker build -t $CONTAINER_IMAGE:1.4 .
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS
- docker push $CONTAINER_IMAGE:1.4
- docker build -t $CONTAINER_IMAGE:$IMAGE_VERSION .
- docker push $CONTAINER_IMAGE:$IMAGE_VERSION
- docker logout

64
README.MD Normal file
View File

@@ -0,0 +1,64 @@
# SpringBoot 测试样板工程
## 用途
- Docker环境测试
- CICD测试
- Java环境测试
- 端口、端口转发测试
## 用法
默认暴露端口8080
健康检查路径:`/actuator/beans`、`/actuator/info`
**请求样例**
```
GET http://localhost:8080/actuator/info
```
返回结果
```json
{
"app": {
"author": "F嘉阳",
"encoding": "UTF-8"
}
}
```
## 样例接口
**请求URL**
```
GET/POST/PUT/DELETE http://localhost:8080/print/{content}
```
**参数:**
| 参数名 | 类型 | 必选 | 内容 | 说明 |
| :------ | ---- | :--- | :--- | -------- |
| content | 字符 | 否 | info | 输出内容 |
**请求样例**
```
http://localhost:8080/print/info
```
**返回示例**
```json
hello , info
```

17
pom.xml
View File

@@ -23,6 +23,23 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- tomcat加载优先级高于jetty若不加排除则仍然加载tomcat -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 使用 Jetty 容器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>

View File

@@ -14,7 +14,7 @@ public class DemoApplication {
SpringApplication.run(DemoApplication.class, args);
}
@RequestMapping("/{content}")
@RequestMapping("/print/{content}")
public String helloWorld(@PathVariable(name = "content", required = false) String content) {
return "hello , " + content;
}

View File

@@ -1,2 +1,14 @@
server:
port: 8080
port: 8080
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
info:
app:
author: F嘉阳
encoding: @project.build.sourceEncoding@