没有注册表的JHIpster微服务应用程序为UAA注册表生成配置

时间:2017-07-14 19:57:41

标签: jhipster jhipster-registry

为什么Yeoman Jhipster generator会为JHipster UAA生成JHipster Registry服务注册代码,即使我们指定在JHipster Registry应用生成期间我们不会使用Microservice

以下是我在Micorservice应用程序生成期间选择的选项

? (1/16) Which *type* of application would you like to create? Microservice application
? (2/16) What is the base name of your application? service
? (3/16) As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts. 8081
? (4/16) What is your default Java package name? com.test

################ Jhipster registry not to be used ##########################
? (5/16) Do you want to use the JHipster Registry to configure, monitor and scale your microservices and gateways? No

################ Use Jhipster UAA #######################################
? (6/16) Which *type* of authentication would you like to use? [BETA] Authentication with JHipster UAA server (the server must be generated separately)
? (7/16) What is the folder path of your UAA application? ../uaa

? (8/16) Which *type* of database would you like to use? SQL (H2, MySQL, MariaDB, PostgreSQL, Oracle)
? (9/16) Which *production* database would you like to use? PostgreSQL
? (10/16) Which *development* database would you like to use? H2 with in-memory persistence
? (11/16) Do you want to use Hibernate 2nd level cache? No
? (12/16) Would you like to use Maven or Gradle for building the backend? Maven
? (13/16) Which other technologies would you like to use?
? (14/16) Would you like to enable internationalization support? No
? (15/16) Besides JUnit and Karma, which testing frameworks would you like to use?
? (16/16) Would you like to install other generators from the JHipster Marketplace? No

在生成应用程序后选择这些选项后,UAA内的application-dev.yml具有以下配置

jhipster:
    http:
        version: V_1_1 # To use HTTP/2 you will need SSL support (see above the "server.ssl" configuration)
    # CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API
    cors:
        allowed-origins: "*"
        allowed-methods: GET, PUT, POST, DELETE, OPTIONS
        allowed-headers: "*"
        exposed-headers:
        allow-credentials: true
        max-age: 1800
    security:
        client-authorization:
            access-token-uri: http://uaa/oauth/token
            token-service-id: uaa ############ Why does it need service ID if it's not dependenty on Jhipster Registry
            client-id: internal
            client-secret: internal

以下是UAA

的两行
access-token-uri: http://uaa/oauth/token
token-service-id: uaa

可以看出,微服务配置是为了寻找名为uaa的服务而创建的。如果此应用程序不依赖于Jhipster Registry或任何其他注册表,为什么此配置正在寻找已注册的服务名称?

我希望我只需要指定UAA URL和凭据,这应该是没有注册表的。

感谢任何帮助。

Jhipster版

{
  "devDependencies": {
    "generator-jhipster": "4.6.1"
  }
}

yo jhipster:info

的输出
##### **JHipster Version(s)**

```
C:\workspace\test3\service
`-- generator-jhipster@4.6.1 

```


##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**


<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.test"
    },
    "jhipsterVersion": "4.6.1",
    "baseName": "service",
    "packageName": "com.test",
    "packageFolder": "com/test",
    "serverPort": "8081",
    "authenticationType": "uaa",
    "uaaBaseName": "uaa",
    "hibernateCache": "no",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "enableTranslation": false,
    "applicationType": "microservice",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "skipClient": true,
    "skipUserManagement": true,
    "clientPackageManager": "npm"
  }
}
</pre>
</details>


##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>





</pre>
</details>


##### **Environment and Tools**

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8

git version 2.10.0.windows.1

node: v6.11.1

npm: 3.9.6

bower: 1.7.7

gulp:
[07:50:35] CLI version 3.9.1

yeoman: 2.0.0

1 个答案:

答案 0 :(得分:0)

很抱歉,您的回答很晚。生成的代码中唯一真正不必要的部分是“ token-service-id”,因为它专门用于在应用程序堆栈内部(例如Netflix Eureka,Consul等)进行服务发现。

如果没有服务发现,则仍然需要您的应用程序才能访问UAA。因此,仅保留access-token-uri就足够了,而无需填充token-service-id标志。

如果您的应用程序能够解析提供的URI,则基本上可以正常工作。但是,如果没有,请随时在GitHub上发布问题。

相关问题