SpringCloud 主服务加了security 登陆认证后 Client 连接不上的问题

问题事故: SpringCloud 主服务加了security 登陆认证后,突然client客户端全部连接不上了?

解决办法:修改主服务启动类:

@SpringBootApplication
@EnableEurekaServer
public class NetworkBusServerApplication extends WebSecurityConfigurerAdapter{
    static Logger logger = LoggerFactory.getLogger(NetworkBusServerApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(NetworkBusServerApplication.class, args);
        logger.info("Springcloud 主服务启动完成!");
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // Configure HttpSecurity as needed (e.g. enable http basic).
//        http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);
        http.csrf().disable();
        //注意:为了可以使用 http://${user}:${password}@${host}:${port}/eureka/ 这种方式登录,所以必须是httpBasic,
        // 如果是form方式,不能使用url格式登录
        http.authorizeRequests().anyRequest().authenticated().and().httpBasic();

    }

 

你可能感兴趣的:(SpringCloud)