0

为什么即使我们指定在应用程序生成期间不使用,也会生成用于服务注册的Yeoman Jhipster generator代码。JHipster UAAJHipster RegistryJHipster RegistryMicroservice

以下是我在生成 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 和凭据,并且在没有注册表的情况下应该是这样。

任何帮助表示赞赏。

极品版

{
  "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
4

1 回答 1

0

抱歉回复晚了。唯一真正不必要的生成代码是“token-service-id”,因为这是特定于在您的应用程序堆栈中进行服务发现(例如,Netflix Eureka、Consul 等)

如果您没有服务发现,您仍然需要您的应用程序来访问 UAA。所以只保留access-token-uri并且不需要填充token-service-id标志就足够了。

基本上,如果您的应用程序能够解析提供的 URI,它应该可以工作。但如果没有,请随时在 GitHub 上打开一个问题。

于 2018-06-21T09:28:22.093 回答