Reputation: 115
I have generated a microservice configured for consul with jhipster 4.6.2. I'm running Consul with Docker (with Virtualbox).
As a result, it is not running on localhost (but e.g. with 192.168.99.100).
Hence I modified application-dev.yml of my microservice to set the host like this :
cloud: consul: discovery: prefer-ip-address: true host: 192.168.99.100 port: 8500
... but when I start the micro-service, it is still trying to connect to localhost (i.e. the property below is not taken into account). Then I got this exception :
com.ecwid.consul.transport.TransportException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8500 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1, localhost/fe80:0:0:0:0:0:0:1%1] failed: Connection refused
Any idea ?
thanks !
My config jhipster:
{
"generator-jhipster": {
"promptValues": {
"packageName": "org.fge.msconsul"
},
"jhipsterVersion": "4.6.2",
"baseName": "msconsul",
"packageName": "org.fge.msconsul",
"packageFolder": "org/fge/msconsul",
"serverPort": "8082",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "consul",
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "replaced-by-jhipster-info",
"enableTranslation": false,
"applicationType": "microservice",
"testFrameworks": [],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"clientPackageManager": "yarn"
}
}
</details>
##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**
##### **Environment and Tools**
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
git version 2.11.0 (Apple Git-81)
node: v7.4.0
npm: 5.0.3
bower: 1.8.0
gulp:
[22:45:50] CLI version 3.9.1
yeoman: 2.0.0
yarn: 0.27.5
Docker version 17.05.0-ce, build 89658be
docker-compose version 1.13.0, build 1719ceb
Execution complete
Upvotes: 3
Views: 9851
Reputation: 2694
You can also mention in application.properties the consul host like below, i have confirmed that this works
spring.cloud.consul.host=http://hostname
spring.cloud.consul.port=8500
the best way to mention this is bootstrap.yml which is loaded first before any .properties are loaded
Upvotes: 1
Reputation: 16284
Spring Cloud has a bootstrap phase from which it can load configuration properties from the external sources.
src/main/resources/bootstrap*.yml
is the file where you must configure how to connect to Consul.
Upvotes: 4