2 Star 5 Fork 5

cuiliang / sprint-boot-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

项目说明

最简单的springboot项目,用于测试java项目打包部署等功能。

版本依赖

Openjdk:17.0.7

Maven:3.9.3

Spring Boot:3.1.1

打包构建

# 在项目根目录执行命令
mvn clean package
# 控制台输出如下内容表示打包成功
[INFO] Replacing main artifact /Users/cuiliang/IdeaProjects/SpringBootDemo/target/SpringBootDemo-0.0.1-SNAPSHOT.jar with repackaged archive, adding nested dependencies in BOOT-INF/.
[INFO] The original artifact has been renamed to /Users/cuiliang/IdeaProjects/SpringBootDemo/target/SpringBootDemo-0.0.1-SNAPSHOT.jar.original
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:04 min
[INFO] Finished at: 2023-07-02T10:44:22+08:00
[INFO] ------------------------------------------------------------------------

运行项目

java -jar target/SpringBootDemo-0.0.1-SNAPSHOT.jar
# 控制台输出以下内容表示运行成功
2023-07-02T10:46:55.109+08:00  INFO 5554 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8888 (http) with context path ''
2023-07-02T10:46:55.136+08:00  INFO 5554 --- [           main] c.e.s.SpringBootDemoApplication          : Started SpringBootDemoApplication in 2.288 seconds (process running for 2.76)

访问测试

➜  SpringBootDemo git:(main) ✗ curl 127.0.0.1:8888/       
Hello SpringBoot Version:v1   
➜  SpringBootDemo git:(main) ✗ curl 127.0.0.1:8888/health
ok

修改首页输出内容

修改文件:com/example/springbootdemo/HelloWorldController.java

修改内容:public String hello() { return "Hello SpringBoot Version:v1"; }

构建docker镜像并部署

➜  SpringBootDemo git:(main) ✗ docker build -t springboot_demo:v1 .   
➜  SpringBootDemo git:(main) ✗ docker run -d -p 8888:8888 --name springboot_demo springboot_demo:v1
MIT License Copyright (c) 2023 cuiliang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

最简单的springboot项目,用于测试java项目打包部署等功能。 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/cuiliang0302/sprint_boot_demo.git
git@gitee.com:cuiliang0302/sprint_boot_demo.git
cuiliang0302
sprint_boot_demo
sprint-boot-demo
master

搜索帮助