小编给大家分享一下Java微服务应用测试的示例分析,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧! package com.jeanron.licensesservice.domain; public class Licen
小编给大家分享一下Java微服务应用测试的示例分析,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
package com.jeanron.licensesservice.domain; public class License{ private String licenseId; private String organizationId; private String productName; private String licenseType; public String getLicenseId() { return licenseId; } public void setLicenseId(String licenseId) { this.licenseId = licenseId; } public String getOrganizationId() { return organizationId; } public void setOrganizationId(String organizationId) { this.organizationId = organizationId; } public String getProductName() { return productName; } public void setProductName(String productName) { this.productName = productName; } public String getLicenseType() { return licenseType; } public void setLicenseType(String licenseType) { this.licenseType = licenseType; } public License withLicenseId(String licenseId){ this.setLicenseId( licenseId ); return this; } public License withOrganizationId(String organizationId){ this.setOrganizationId(organizationId); return this; } public License withProductName(String productName){ this.setProductName(productName); return this; } public License withLicenseType(String licenseType){ this.setLicenseType(licenseType); return this; }}
package com.jeanron.licensesservice.controller; import org.springframework.Http.httpstatus; import org.springframework.WEB.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import com.jeanron.licensesservice.domain.License; @RestController @RequestMapping(value="v1/organizations/{organizationId}/licenses") public class LicenseServiceController { @RequestMapping(value="/{licenseId}",method = RequestMethod.GET)public License getLicenses( @PathVariable("organizationId") String organizationId, @PathVariable("licenseId")String licenseId) { //@PathVariable能将URL中{organizationId}、{licenseId}映射到方法的变量organizationId、licenseId return new License() .withLicenseId(licenseId) .withOrganizationId(organizationId) .withProductName("Opsapi") .withLicenseType("Database"); }@RequestMapping(value="{licenseId}",method = RequestMethod.PUT) public String updateLicenses( @PathVariable("licenseId") String licenseId) { return String.fORMat("This is the put"); }@RequestMapping(value="{licenseId}",method = RequestMethod.POST) public String saveLicenses( @PathVariable("licenseId") String licenseId) { return String.format("This is the post"); }@RequestMapping(value="{licenseId}",method = RequestMethod.DELETE)@ResponseStatus(HttpStatus.NO_CONTENT) public String deleteLicenses( @PathVariable("licenseId") String licenseId) { return String.format("This is the Delete");}}
看代码还OK,但是实际配置的时候,第二个类的环境配置是个难点,很容易漏掉一些东西,导致编译失败。我能给出的建议就是耐心一些,再耐心一些。
启动下服务,idea里面启动还是很方便的。
通过浏览器,我们能够根据输入的参数,经过处理,封装成一个JSON串返回。
看完了这篇文章,相信你对“Java微服务应用测试的示例分析”有了一定的了解,如果想了解更多相关知识,欢迎关注编程网精选频道,感谢各位的阅读!
--结束END--
本文标题: Java微服务应用测试的示例分析
本文链接: https://www.lsjlt.com/news/237343.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
一口价域名售卖能注册吗?域名是网站的标识,简短且易于记忆,为在线用户提供了访问我们网站的简单路径。一口价是在域名交易中一种常见的模式,而这种通常是针对已经被注册的域名转售给其他人的一种方式。
一口价域名买卖的过程通常包括以下几个步骤:
1.寻找:买家需要在域名售卖平台上找到心仪的一口价域名。平台通常会为每个可售的域名提供详细的描述,包括价格、年龄、流
443px" 443px) https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294.jpg https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294-768x413.jpg 域名售卖 域名一口价售卖 游戏音频 赋值/切片 框架优势 评估指南 项目规模
0