refactor: demo/app-simple 更名为 demo/app
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
target/
|
||||
.git/
|
||||
.DS_Store
|
||||
@@ -0,0 +1,3 @@
|
||||
target/
|
||||
.idea/
|
||||
*.iml
|
||||
@@ -0,0 +1,18 @@
|
||||
# 编译阶段:compile-maven3-jdk17(JDK 17 + Maven 3.9.9 + 阿里云 Maven 源)
|
||||
FROM registry.cn-shanghai.aliyuncs.com/odboy/kenaito:compile-maven3-jdk17 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# 先只拷贝 POM 预热依赖层:源码改动不会让依赖缓存失效
|
||||
COPY pom.xml ./
|
||||
RUN mvn -B -q dependency:go-offline
|
||||
|
||||
COPY src ./src
|
||||
RUN mvn -B -q clean package -DskipTests
|
||||
|
||||
# 运行阶段:自建 runtime-tomcat10(runtime-jdk17 + Tomcat 10.1.34,Servlet 6.0 / Jakarta EE 10,对应 Spring 6)
|
||||
FROM registry.cn-shanghai.aliyuncs.com/odboy/kenaito:runtime-tomcat10 AS runtime
|
||||
LABEL MAINTAINER="tianjun@odboy.cn"
|
||||
WORKDIR /home/admin
|
||||
# 带版本号的 war 改名后部署,上下文路径 = /spring-war17
|
||||
# 基础镜像已清空 webapps/*,时区、curl、EXPOSE 8080、ENTRYPOINT catalina.sh run 均由基础镜像提供
|
||||
COPY --from=build /src/target/spring-war17.war ${CATALINA_HOME}/webapps/spring-war17.war
|
||||
@@ -0,0 +1,101 @@
|
||||
# spring-war17 示例
|
||||
|
||||
演示如何用 `compile-maven3-jdk17` 打出 **war 包**,再部署到外置 Tomcat 10.1 运行。与
|
||||
[`demo/app-simple/springboot-jar17`](../springboot-jar17/README.md) 对照:应用代码几乎一样,区别只在打包方式与运行容器。
|
||||
|
||||
| 阶段 | 镜像 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| 编译 | `registry.cn-shanghai.aliyuncs.com/odboy/kenaito:compile-maven3-jdk17` | JDK 17 + Maven 3.9.9 + 阿里云 Maven 源(见 `image/compile-maven3-jdk17`) |
|
||||
| 运行 | `registry.cn-shanghai.aliyuncs.com/odboy/kenaito:runtime-tomcat10` | 自建镜像:JDK 17 + Tomcat 10.1.34(Servlet 6.0 / Jakarta EE 10,对应 Spring 6),见 `image/runtime-tomcat10` |
|
||||
|
||||
> Spring 6 要求 Jakarta EE 9+,即 **Tomcat 10.1 及以上**;Tomcat 9(`javax.servlet`)跑不了本示例。
|
||||
|
||||
### 示例内容
|
||||
|
||||
```
|
||||
spring-war17/
|
||||
├── pom.xml # packaging=war,Spring 6.2.1 + Thymeleaf 3.1 + Jackson 2.18,不依赖 Boot
|
||||
├── src/main/java/cn/odboy/demo/
|
||||
│ ├── WebAppInitializer.java # 替代 web.xml,注册 DispatcherServlet(映射 /api/*)
|
||||
│ ├── WebConfig.java # @EnableWebMvc + Thymeleaf 视图解析 + Jackson
|
||||
│ ├── DemoController.java # @RestController:/ 、/info、/hello/{name}(在 /api 前缀下)
|
||||
│ └── PageController.java # @Controller:/api/page 渲染模板
|
||||
├── src/main/resources/templates/index.html
|
||||
├── src/main/webapp/WEB-INF/web.xml # 仅声明 metadata-complete=false 与会话超时,无 servlet 映射
|
||||
├── Dockerfile # 两阶段:compile-maven3-jdk17 -> runtime-tomcat10
|
||||
├── build.sh # 构建镜像(PUSH=1 时同时推送)
|
||||
├── docker-compose.yml # 部署编排(8085 -> 容器 8080,固定 IP 172.30.2.20)
|
||||
├── startup.sh # docker-compose up -d
|
||||
└── shutdown.sh # docker-compose down
|
||||
```
|
||||
|
||||
### 构建与部署
|
||||
|
||||
```shell
|
||||
sh build.sh # docker build -t registry.cn-shanghai.aliyuncs.com/odboy/kenaito:demo-spring-war17 .
|
||||
PUSH=1 sh build.sh # 构建并推送
|
||||
sh startup.sh # docker-compose -f docker-compose.yml -p spring-war17-demo up -d
|
||||
```
|
||||
|
||||
war 部署后上下文路径为 **`/spring-war17`**,接口都在该前缀下:
|
||||
|
||||
```shell
|
||||
curl http://127.0.0.1:8085/spring-war17/api/ # {"message":"spring-war17 is running","java":"17.0.x",...}
|
||||
curl http://127.0.0.1:8085/spring-war17/api/info # 同上
|
||||
curl http://127.0.0.1:8085/spring-war17/api/hello/demo
|
||||
```
|
||||
|
||||
浏览器打开 http://127.0.0.1:8085/spring-war17/api/page 可看到渲染后的运行信息页面。
|
||||
|
||||
### 关键点
|
||||
|
||||
**没有 servlet 映射的 web.xml**:`WebAppInitializer` 继承 `AbstractAnnotationConfigDispatcherServletInitializer`,
|
||||
Tomcat 通过 Servlet 3+ 的 `ServletContainerInitializer` 机制自动发现它并注册 DispatcherServlet。
|
||||
`src/main/webapp/WEB-INF/web.xml` 只声明 `metadata-complete="false"` 和会话超时,不写任何 servlet 映射;
|
||||
`maven-war-plugin` 设置了 `failOnMissingWebXml=false`,即使删掉它也能打包。
|
||||
|
||||
**DispatcherServlet 只映射 `/api/*`**:`/api` 前缀外的请求仍由 Tomcat 默认 Servlet 处理(404 或欢迎页),
|
||||
避免传统 war 里 DispatcherServlet 抢占 `/` 后静态资源失效。`web.xml` 式项目可以同样用 `<url-pattern>/api/*</url-pattern>`。
|
||||
|
||||
**context.xml**:`src/main/webapp/META-INF/context.xml` 只是占位文件,用来把该目录纳入构建上下文;
|
||||
它不参与启动流程,删掉不影响运行。
|
||||
|
||||
**上下文路径**:war 文件名即上下文路径,`finalName` 固定为 `spring-war17`,所以是 `/spring-war17`。
|
||||
想让应用直接挂在根路径 `/`,把 war 改名为 `ROOT.war` 即可。
|
||||
|
||||
**两阶段构建**:build 阶段在 `compile-maven3-jdk17` 里 `mvn package`,runtime 阶段只把 war 拷进官方 Tomcat 镜像,
|
||||
运行镜像不含 Maven/源码。Tomcat 镜像保留官方默认布局,只清空自带 `webapps/*`。
|
||||
|
||||
**端口**:容器内 Tomcat 仍是 8080(官方镜像默认),宿主机映射到 8085。
|
||||
|
||||
**JSON 输出**:`@EnableWebMvc` 只会注册 Spring 自带的转换器(ByteArray/String/Resource 及 JAXB 等),
|
||||
非 Boot 项目里 **Jackson 不会自动带入**。所以 `pom.xml` 显式声明了 `jackson-databind`,
|
||||
Spring 检测到它会自动注册 `MappingJackson2HttpMessageConverter`,`/api/*` 返回 `Map` 即得 JSON;
|
||||
缺了它就会像最常见的排查题那样返回 `HTTP 406 Not Acceptable`(Tomcat 自己的错误页,`Acceptable representations: []`)。
|
||||
|
||||
**健康检查**:compose 用 `curl` 探测 `/spring-war17/api/info`,`start_period: 30s` 覆盖 war 解压与 Spring 初始化;
|
||||
`runtime-tomcat10` 已装 `curl`,无需额外安装。
|
||||
|
||||
### 运维命令
|
||||
|
||||
```shell
|
||||
docker logs -f spring-war17-demo # catalina.out 日志
|
||||
docker exec spring-war17-demo ls /usr/local/tomcat/webapps # 查看已部署应用(war 与解包目录)
|
||||
docker exec spring-war17-demo java -version # 确认 JDK 版本
|
||||
```
|
||||
|
||||
### 调试时直接在编译镜像里跑
|
||||
|
||||
```shell
|
||||
docker run --rm -it -v "$PWD":/src -w /src \
|
||||
registry.cn-shanghai.aliyuncs.com/odboy/kenaito:compile-maven3-jdk17 \
|
||||
mvn -B clean package
|
||||
```
|
||||
|
||||
得到的 `target/spring-war17.war` 可以拷到任意 Tomcat 10.1 的 `webapps/` 下部署。
|
||||
|
||||
### 停止
|
||||
|
||||
```shell
|
||||
sh shutdown.sh
|
||||
```
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# 在示例目录下构建示例镜像(编译 + 运行两阶段均在本机 docker 内完成)
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
IMAGE=${IMAGE:-registry.cn-shanghai.aliyuncs.com/odboy/kenaito:demo-spring-war17}
|
||||
docker build -t "${IMAGE}" .
|
||||
|
||||
if [ "${PUSH:-0}" = "1" ]; then
|
||||
docker push "${IMAGE}"
|
||||
fi
|
||||
@@ -0,0 +1,30 @@
|
||||
version: '3.8'
|
||||
|
||||
networks:
|
||||
spring-war17-demo:
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: "172.30.2.0/24"
|
||||
|
||||
services:
|
||||
demo:
|
||||
image: registry.cn-shanghai.aliyuncs.com/odboy/kenaito:demo-spring-war17 # 镜像由 build.sh 构建
|
||||
container_name: spring-war17-demo
|
||||
restart: unless-stopped
|
||||
ports: # 映射端口:8085 -> 容器内 Tomcat 8080
|
||||
- "8085:8080"
|
||||
environment: # 设置环境变量,相当于docker run命令中的-e
|
||||
TZ: Asia/Shanghai
|
||||
JAVA_OPTS: "-Xms128m -Xmx256m -Duser.timezone=Asia/Shanghai"
|
||||
CATALINA_OPTS: "-Djava.security.egd=file:/dev/./urandom"
|
||||
healthcheck:
|
||||
# runtime-tomcat10 已装 curl,直接探测健康页面;start_period 覆盖 war 解压与 Spring 初始化
|
||||
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:8080/spring-war17/api/info > /dev/null"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
networks:
|
||||
spring-war17-demo:
|
||||
ipv4_address: 172.30.2.20
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>cn.odboy</groupId>
|
||||
<artifactId>spring-war17</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<!-- war 包,部署到外置 Tomcat 10.1;不用 Boot 父 POM,版本全部显式声明 -->
|
||||
<packaging>war</packaging>
|
||||
<name>spring-war17</name>
|
||||
<description>Spring MVC 6 + 外置 Tomcat 10.1 的 war 包示例</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.release>${java.version}</maven.compiler.release>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.version>6.2.1</spring.version>
|
||||
<thymeleaf-spring6.version>3.1.2.RELEASE</thymeleaf-spring6.version>
|
||||
<jackson.version>2.18.2</jackson.version>
|
||||
<jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- spring-webmvc 已传递 spring-core/beans/context/web/aop/expression -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-spring6</artifactId>
|
||||
<version>${thymeleaf-spring6.version}</version>
|
||||
</dependency>
|
||||
<!-- JSON 序列化:非 Boot 项目不会自动带入 Jackson,@RestController 返回 Map 必须显式声明 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<!-- JSP/Servlet API 由 Tomcat 提供,编译期需要,不打进 war -->
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<version>${jakarta.servlet-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- spring-war17.war,部署后上下文路径即 /spring-war17(也可改名) -->
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<release>${java.version}</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 去掉版本号,war 文件名与 upstream/ 部署名一致 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
docker-compose -f docker-compose.yml -p spring-war17-demo down
|
||||
@@ -0,0 +1,75 @@
|
||||
package cn.odboy.demo;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.time.Duration;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.SpringVersion;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 运行时信息接口。与 demo/app-simple/springboot-jar17 里的同名类保持一致的输出结构,方便对比 jar 与 war 两种打包方式。
|
||||
*/
|
||||
@RestController
|
||||
public class DemoController {
|
||||
|
||||
private static final ZoneId TZ8 = ZoneId.of("Asia/Shanghai");
|
||||
private static final DateTimeFormatter TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss XXX");
|
||||
|
||||
@Autowired(required = false)
|
||||
private ServletContext servletContext;
|
||||
|
||||
@GetMapping({"/", "/info"})
|
||||
public Map<String, Object> info() {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
long uptimeMillis = ManagementFactory.getRuntimeMXBean().getUptime();
|
||||
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
body.put("message", "spring-war17 is running");
|
||||
body.put("java", System.getProperty("java.version"));
|
||||
body.put("javaHome", System.getProperty("java.home"));
|
||||
body.put("vm", System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version"));
|
||||
body.put("spring", SpringVersion.getVersion());
|
||||
body.put("application", "Spring MVC " + SpringVersion.getVersion() + " + " + servletContextName());
|
||||
body.put("os", System.getProperty("os.name") + " " + System.getProperty("os.arch"));
|
||||
body.put("hostname", hostname());
|
||||
body.put("contextPath", servletContext == null ? "" : servletContext.getContextPath());
|
||||
body.put("zoneId", ZoneId.systemDefault().getId());
|
||||
body.put("time", ZonedDateTime.now(TZ8).format(TIME_FMT));
|
||||
body.put("uptime", Duration.ofMillis(uptimeMillis).toString());
|
||||
body.put("memory", runtime.totalMemory() / 1024 / 1024 + "MB / max " + runtime.maxMemory() / 1024 / 1024 + "MB");
|
||||
return body;
|
||||
}
|
||||
|
||||
@GetMapping("/hello/{name}")
|
||||
public Map<String, Object> hello(@PathVariable String name) {
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
body.put("message", "Hello, " + name + "!");
|
||||
body.put("time", ZonedDateTime.now(TZ8).format(TIME_FMT));
|
||||
return body;
|
||||
}
|
||||
|
||||
private String servletContextName() {
|
||||
if (servletContext == null) {
|
||||
return "Tomcat";
|
||||
}
|
||||
return servletContext.getServerInfo();
|
||||
}
|
||||
|
||||
private static String hostname() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception e) {
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.odboy.demo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* 页面路由,模板见 src/main/resources/templates/index.html。
|
||||
*/
|
||||
@Controller
|
||||
public class PageController {
|
||||
|
||||
private final DemoController demoController;
|
||||
|
||||
public PageController(DemoController demoController) {
|
||||
this.demoController = demoController;
|
||||
}
|
||||
|
||||
/** 渲染 templates/index.html;/api/page 返回页面,其它 /api/* 仍返回 JSON */
|
||||
@GetMapping("/page")
|
||||
public String page(Model model) {
|
||||
Map<String, Object> info = demoController.info();
|
||||
model.addAttribute("info", info);
|
||||
return "index";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.odboy.demo;
|
||||
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||
|
||||
/**
|
||||
* 替代 web.xml:Tomcat 10.1 启动时通过 Servlet 3+ 的 ServiceLoader 发现本类,
|
||||
* 由它注册 DispatcherServlet 与根容器。前缀 /api 的请求进 Spring MVC,其余请求交给 Tomcat 默认 Servlet。
|
||||
*/
|
||||
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getRootConfigClasses() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getServletConfigClasses() {
|
||||
return new Class<?>[]{WebConfig.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getServletMappings() {
|
||||
return new String[]{"/api/*"};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.odboy.demo;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.thymeleaf.spring6.SpringTemplateEngine;
|
||||
import org.thymeleaf.spring6.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
||||
|
||||
/**
|
||||
* Spring MVC 配置。@EnableWebMvc 已注册包括 Jackson JSON 在内的默认消息转换器,
|
||||
* 这里只额外加上 Thymeleaf 视图解析。
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ComponentScan("cn.odboy.demo")
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureViewResolvers(ViewResolverRegistry registry) {
|
||||
ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
|
||||
// 与 springboot-jar17 保持同一套模板路径:src/main/resources/templates/*.html
|
||||
resolver.setPrefix("templates/");
|
||||
resolver.setSuffix(".html");
|
||||
resolver.setTemplateMode("HTML");
|
||||
resolver.setCharacterEncoding("UTF-8");
|
||||
resolver.setCacheable(true);
|
||||
|
||||
SpringTemplateEngine engine = new SpringTemplateEngine();
|
||||
engine.setTemplateResolver(resolver);
|
||||
|
||||
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
|
||||
viewResolver.setTemplateEngine(engine);
|
||||
viewResolver.setCharacterEncoding("UTF-8");
|
||||
viewResolver.setOrder(1);
|
||||
registry.viewResolver(viewResolver);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>spring-war17 运行信息</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; margin: 40px; color: #222; }
|
||||
h1 { font-size: 20px; }
|
||||
table { border-collapse: collapse; min-width: 520px; }
|
||||
th, td { border: 1px solid #ddd; padding: 6px 12px; text-align: left; }
|
||||
th { background: #f5f5f5; width: 160px; }
|
||||
code { background: #f5f5f5; padding: 1px 4px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>spring-war17 运行信息</h1>
|
||||
<table>
|
||||
<tr th:each="entry : ${info}">
|
||||
<th th:text="${entry.key}">key</th>
|
||||
<td th:text="${entry.value}">value</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
其他接口:<code>api/info</code>、<code>api/hello/{name}</code>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Tomcat 部署描述符,不影响 Spring 初始化。当前版本没有用 web.xml 写 servlet 映射,
|
||||
由 WebAppInitializer(ServletContainerInitializer)注册 DispatcherServlet。
|
||||
要改会话超时或 MIME 类型时才需要改这里。
|
||||
-->
|
||||
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
|
||||
version="6.0"
|
||||
metadata-complete="false">
|
||||
|
||||
<display-name>spring-war17</display-name>
|
||||
|
||||
<session-config>
|
||||
<session-timeout>30</session-timeout>
|
||||
</session-config>
|
||||
|
||||
</web-app>
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
docker-compose -f docker-compose.yml -p spring-war17-demo up -d
|
||||
Reference in New Issue
Block a user