gpt4 book ai didi

spring - 此行有多个标记 - NoOpPasswordEncoder 类型已弃用 - NoOpPasswordEncoder 类型中的 getInstance() 方法已弃用

转载 作者:行者123 更新时间:2023-12-04 02:57:42 26 4
gpt4 key购买 nike

我正在研究 Spring Cloud + Boot 示例。在此示例中,我希望执行 SSO。当我运行这个应用程序时,我得到了很好的响应,但看起来像

Multiple markers at this line - The type NoOpPasswordEncoder is deprecated - The method getInstance() from the type NoOpPasswordEncoder is deprecated



application.properties
server.port: 9000
server.servlet.context-path: /services
security.oauth2.client.clientId: pluralsight
security.oauth2.client.clientSecret: pluralsightsecret
security.oauth2.client.authorized-grant-types: authorization_code,refresh_token,password,client_credentials
security.oauth2.client.scope:toll_read,toll_report

ServiceConfig.java
@Configuration
public class ServiceConfig extends GlobalAuthenticationConfigurerAdapter {

@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.passwordEncoder(NoOpPasswordEncoder.getInstance())
.withUser("agoldberg").password("pass1").roles("USER")
.and()
.withUser("bgoldberg").password("pass2").roles("USER", "OPERATOR");
}
}

主方法:
@SpringBootApplication
@EnableAuthorizationServer
public class PluralsightSpringcloudM4SecureauthserverApplication {

public static void main(String[] args) {
SpringApplication.run(PluralsightSpringcloudM4SecureauthserverApplication.class, args);
}
}

但是 STS,显示错误。不推荐使用的方法的替代方法是什么?

enter image description here

输出:
enter image description here

最佳答案

我能够使用下面的代码解决这个问题。我使用的是 Spring Boot 版本 2.0.4.RELEASE .完毕 !

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configuration.GlobalAuthenticationConfigurerAdapter;

@Configuration
public class ServiceConfig extends GlobalAuthenticationConfigurerAdapter {

@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("agoldberg").password("{noop}pass1").roles("USER")
.and()
.withUser("bgoldberg").password("{noop}pass2").roles("USER", "OPERATOR");
}
}

关于spring - 此行有多个标记 - NoOpPasswordEncoder 类型已弃用 - NoOpPasswordEncoder 类型中的 getInstance() 方法已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52134823/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com