此方法不可用于 uaa和gateway幢码。
其中 xxx 代表微服務的名稱
@AuthorizedFeignClient(name = "xxx")
interface XxxClient {
// 此處需要注意 不可用 @GetMapping @PostMapping
@RequestMapping(value = "/api/some-entities/{id}")
SomeEntity getSomeEntityById(Long @Path("id") id);
}
and inject it in any spring service / rest-controller like this
@Resource
private XxxClient xxxClient;
//...
pubic void someAction() {
//...
xxxClient.getEntityById(id);
//..
}
還有一個地方需要配置的 application*.yml
## 其中有以下一段
jhipster:
http:
version: V_1_1 # To use HTTP/2 you will need SSL support (see above the "server.ssl" configuration)
cache: # Cache configuration
hazelcast: # Hazelcast distributed cache
time-to-live-seconds: 3600
backup-count: 1
security:
client-authorization:
access-token-uri: http://uaa/oauth/token
token-service-id: uaa
client-id: internal
client-secret: internal
jhipster.security.client-authorization.client-id 的配置無法被jhipster讀取
## 通過源碼發(fā)現 使用的是 security.client-authorization.client-id
@Configuration
@ConditionalOnClass({ ClientCredentialsResourceDetails.class, LoadBalancerClient.class })
@ConditionalOnProperty("security.client-authorization.client-id")
public class UaaAutoConfiguration {
.....
}
## 將配置文件security節(jié)點移動到jhipster外就可以了苦银。(也許后面的版本會優(yōu)化)
security:
client-authorization:
access-token-uri: http://uaa/oauth/token
token-service-id: uaa
client-id: internal
client-secret: internal