Record the problems encountered by introducing JWT into spring boot---suddenly display the login page by itself

I have only used swagger for two days. Everything was as usual. I wrote a login with token. I finally wrote it. I was about to verify it. I found that swagger appeared on the login interface inexplicably, and I didn’t know the account password. I panicked a lot.

1. Description of phenomenon

 I tried the login account and password written by myself, but I still couldn’t log in. I read the console and didn’t report an error, and the log didn’t work. I didn’t enter the login interface I wrote. With only a few words I knew, I found some clues The console prints as follows, what is the account number without the password, the key is, I need my own login logic,

This..... (Sure enough, the front end and the back end are still sloppy o(* ̄︶ ̄*)o)

2. Solutions

2.1 Method 1 (used by the author)

Because the system made by the author has very low security and authority requirements, and then the author found out through searching information that this is because of the security mechanism made by SpringSecurity, which realizes the login interface. If you refer to dependencies, you need to rewrite the userDetails related classes, so here There is a once and for all solution, that is to kill this buddy, since you can't eat him, then give him up

As for why Spring Security was introduced before, it is estimated that when I borrowed other people's code, I copied it together. After all, the way is too shallow

 2.2 Method 2, use SpringSecurity to rewrite the operation

Because the author's ability is not up to now, and the business is not needed, and it needs to move bricks, so everyone, please try it yourself, click here for the method

Guess you like

Origin blog.csdn.net/liuxin00020/article/details/131435912