本文介绍了在spring spring中注册registerglobal(),configure(),configureglobal(),configureglobalsecurity之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有三个代码片段,它们都在创建内存中的身份验证。那么它如何影响用不同的方法名称定义它?
registerGlobal
configure
configureGlobal
configureGlobalSecurity
ONE
I have below three code snippets all doing the same thing creating in-memory authentication. So how it impacts defining it in different method names?
registerGlobal
configure
configureGlobal
configureGlobalSecurity
ONE
public void registerGlobal(AuthenticationManagerBuilder auth) throws
Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER",
"ADMIN");
}
}
TWO
TWO
@Override
protected void configure(AuthenticationManagerBuilder auth)
throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles
("USER");
}
三
Three
public void configureGlobal(AuthenticationManagerBuilder auth)
throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles
("USER");
}
FOURTH
FOURTH
<pre lang="java">
@Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("user").roles("USER");
}
我的尝试:
搜索spring.io和其他博客,但只找到用法而不是解释
What I have tried:
Searched spring.io and other blogs but only found usages not explanations
推荐答案
@Autowired
public void anyMethodName(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("user").roles("USER");
}
您可以任意命名并且有效
这篇关于在spring spring中注册registerglobal(),configure(),configureglobal(),configureglobalsecurity之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!