sprint-boot eclipse war tomcat 部署

参考:

https://blog.csdn.net/zhoucheng05_13/article/details/77915294

https://blog.csdn.net/mameng1988/article/details/79945760

 

先按照:

https://blog.csdn.net/zhoucheng05_13/article/details/77915294

文里的方法,修改 pom.xml 和 MainApplication

 

然后按照:

https://blog.csdn.net/mameng1988/article/details/79945760

文里的方法,Eclipse中右击项目名称,出现的界面框中点击“Run As”,然后选择“Maven install”等待编译成功,在项目空间的target目录下就可以看到打成的War包:项目名+版本号.war文件。

假设war文件名为 demo.war,spring boot 项目中匹配的路径为 hello

把demo.war 拷贝至 tomcat/webapps/ 目录

 

验证:

再到 tomcat/bin/ 目录下执行 startup.sh 脚本

打开浏览器访问 localhost:8080/demo/hello/

使用Knife4j来生成API接口文档需要以下步骤: 1. 引入Knife4j依赖 在pom.xml中添加以下依赖: ```xml <!--Knife4j--> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>${knife4j.version}</version> </dependency> ``` 2. 配置Knife4j 在application.yml中添加以下配置: ```yaml knife4j: version: 2.0.2 title: 接口文档 description: 接口文档描述 contact: name: xxx url: https://xxx.com email: xxx@xxx.com license: name: Apache License 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html termsOfServiceUrl: https://xxx.com/terms-of-service.html ``` 其中,version为Knife4j的版本号,title为文档标题,description为文档描述,contact为联系人信息,license为许可证信息,termsOfServiceUrl为服务条款链接。 3. 编写接口文档注解 在接口方法上添加接口文档注解,例如: ```java @ApiOperation(value = "获取用户信息", notes = "根据用户ID获取用户信息") @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "Long", paramType = "path") @GetMapping("/{userId}") public UserInfo getUserInfo(@PathVariable Long userId) { //... } ``` 其中,@ApiOperation为方法级别注解,用于描述接口信息,包括value、notes等属性;@ApiImplicitParam为方法参数级别注解,用于描述参数信息,包括name、value、required、dataType等属性。 4. 访问接口文档 启动应用程序后,在浏览器中访问如下地址即可查看生成的API接口文档: ``` http://localhost:port/doc.html ``` 其中,port为应用程序启动的端口号。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Zonson9999

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值