postman測試登錄shiro

springboot項目使用了角色權限shiro管理,我要測試其它的接口但是需要登錄成功后才能測試,解決這個問題有兩種方法。

1.postman直接輸入用戶名和密碼登錄成功后,就可以進行其它的接口測試。

2. 使用swagger先登錄成功后,就可以測試其它的接口了。

一,postman


二、swagger


springboot集成swagger后訪問URL

http://localhost:8080/swagger-ui.html



@Configuration

@EnableSwagger2

public class SwaggerConfig {

? ? @Bean

? ? public Docket api() {

? ? ? ? return new Docket(DocumentationType.SWAGGER_2)

? ? ? ? ? ? ? ? .apiInfo(apiInfo())

? ? ? ? ? ? ? ? .select()

? ? ? ? ? ? ? ? .apis(RequestHandlerSelectors.basePackage("com.baidu.controller")) //自己的控制器包名路徑

? ? ? ? ? ? ? ? .paths(PathSelectors.any())

? ? ? ? ? ? ? ? .build();

? ? }

? ? private ApiInfo apiInfo() {

? ? ? ? return new ApiInfoBuilder()

? ? ? ? ? ? ? ? .title("世界 API文檔")

? ? ? ? ? ? ? ? .description("世界 操作文檔")

? ? ? ? ? ? ? ? //服務條款網(wǎng)址

? ? ? ? ? ? ? ? .termsOfServiceUrl("http://www.baidu.com/")

? ? ? ? ? ? ? ? .version("1.0")

? ? ? ? ? ? ? ? .contact(new Contact("祖國", "http://www.baidu.com/", "123456@qq.com"))

? ? ? ? ? ? ? ? .build();

? ? }

}


pom.xml

<dependency>

? ? ? ? ? ? <groupId>io.springfox</groupId>

? ? ? ? ? ? <artifactId>springfox-swagger2</artifactId>

? ? ? ? ? ? <version>2.9.2</version>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>io.springfox</groupId>

? ? ? ? ? ? <artifactId>springfox-swagger-ui</artifactId>

? ? ? ? ? ? <version>2.9.2</version>

? ? ? ? </dependency>

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容