【发布时间】:2018-11-03 01:11:19
【问题描述】:
我有一个带有配置的 Eureka 服务器
# Eureka configuration
eureka.instance.hostname: localhost
eureka.client.registerWithEureka: false
eureka.client.fetchRegistry: false
eureka.client.serviceUrl.defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
此外,在启用 Eureka Discovery 的情况下运行客户和订单的两个微服务。我想在customers微服务中访问Orders微服务,但是eureka没有发现order微服务。
在我的两个服务中,安全性都是这样实现的
@Configuration
@EnableResourceServer
public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and().authorizeRequests().antMatchers("/api/**").authenticated()
.and().authorizeRequests().antMatchers("/swagger-ui.html").permitAll()
.and().authorizeRequests().antMatchers("/**").authenticated();
}
}
【问题讨论】:
-
下面的答案有帮助吗?
标签: spring-boot microservices netflix-eureka